C++_正则表达式_regex

std::string str = "place B5 at B1";

bool isRight = std::regex_match(str2, std::regex("\\s*(place)\\s+[A-Z]\\d\\s+(at)\\s+[A-Z]\\d\\s*"));


^匹配字符串的开始

$匹配字符串的结束

\s匹配任意空白字符

\s{5,} 这个代表匹配5次或者更多次

\s* 这个代表重复0次或者更多次

\s+这个代表重复1次或者更多次

\s?这个代表重复0次或者1次

参考:

https://blog.csdn.net/fengbingchun/article/details/54835571

你可能感兴趣的:(C++_正则表达式_regex)