Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/cplusplus/128.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/regex/18.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/xml/12.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C++ 基本正则表达式c++;-正斜杠和点_C++_Regex - Fatal编程技术网

C++ 基本正则表达式c++;-正斜杠和点

C++ 基本正则表达式c++;-正斜杠和点,c++,regex,C++,Regex,我想使用c++regex\u match来匹配正斜杠/和点。我读到\/和\.有效。但我得到: 警告:未知转义序列:'\/' 警告:未知转义序列:'\.' 字符串也不正确匹配 我尝试为我的正则表达式设置ECMAScript标志,如下所示: std::regex succes_r("^Sth\/Sth\.Sth).*", std::regex_constants::ECMAScript) 但是没有任何改变。C++不要处理未知的转义,比如\/和\. 应该是“^Sth/Sth\\\.Sth)。*”,它

我想使用c++
regex\u match来匹配正斜杠
/
和点
。我读到
\/
\.
有效。但我得到:

警告:未知转义序列:'\/'

警告:未知转义序列:'\.'

字符串也不正确匹配

我尝试为我的正则表达式设置ECMAScript标志,如下所示:

std::regex succes_r("^Sth\/Sth\.Sth).*", std::regex_constants::ECMAScript)

但是没有任何改变。

C++不要处理未知的转义,比如
\/
\.

应该是
“^Sth/Sth\\\.Sth)。*”
,它被解析并交给
正则表达式引擎为
^Sth/Sth\.Sth.*


请注意,正斜杠不是正则表达式的特殊字符。

使用。请注意,
\
在c++中是一个特殊字符,因此您也需要转义它。