Regex \w escaping in C++11

后端 未结 2 757
情歌与酒
情歌与酒 2021-01-15 17:04

This code isn\'t returning anything, am I escaping the w character the wrong way??

http://liveworkspace.org/code/3bRWOJ$38

#include 
         


        
2条回答
  •  离开以前
    2021-01-15 17:43

    As @DanielFrey said, for an ordinary string literal you have to double-up the backslashes. With C++11 you can use a raw string literal instead: R"(\w)". The 'R' turns off handling of special characters, so the backslash is just a backslash. The parentheses mark the beginning and end of the raw string literal and are not part of the text.

提交回复
热议问题