C++ regex正则表达式的规则和其他语言差不多,如下:
特殊字符(用于匹配很难形容的字符)
characters | description | matches |
---|---|---|
\d | digit | a decimal digit character |
注意: 在C++中反斜杠(\)会转义
std::regex e1("\\d"); // \d -> 匹配数字字符
std::regex e2("\\\\"); // \\ -> 匹配反斜杠字符
数量:
characters | times | effects |
---|---|---|
* | 0 or more | the preceding atom is matched 0 or more times |
+ | 1 or more | the preceding atom is matched 1 or more times |