C++ Regex not matching with a token in string
Regex is not matching a token { in string –
string:
{ int b = 10; }
code:
std::cout << std::regex_match(line, m, std::regex("\\{")) << std::endl;
std::cout << std::regex_match(line, m, std::regex("([A-Za-z0-9_]+) ([\\{]+)")) << std::endl;
std::cout << std::regex_match(line, m, std::regex("([\\{])")) << std::endl;
std::cout << std::regex_match(line, m, std::regex("([\\{]\n)")) << std::endl;
output:
{ int b = 10; }
0
0
0
0
I can’t find what I’ve missed out.
Read more here: Source link
