正则表达式

flyingssky 2020-06-13

正则表达式学习网址:https://www.runoob.com/regexp/regexp-tutorial.html

正则表达式在线测试:https://c.runoob.com/front-end/854

正则表达式学习示例

1、^InterGateway\.\d\.(user|name)$

    可以匹配 InterGateway.1.user  或 InterGateway.2.name

 2、regex_replace

      string str = "InterGateway.device.1.user";

      regex pattern("^(InterGateway\.device\.)\d\.(user|name)$");

      regex_replace(str, pattern, "$1$2")    ===>  InterGateway.device.user

相关推荐