1

I am using the following code and the regex match is failing

std::regex reg("^Program Files");
if(std::regex_match("Program Files (x86)",reg)
{
  return true;
}

I tried this regex here and it seems to work. Any suggestions why my if condition is not returning true ?

Rajeshwar
  • 11,179
  • 26
  • 86
  • 158

1 Answers1

0

You want regex_search(), not regex_match(). The regex_match() function always matches against the complete string.

Ross Smith
  • 3,719
  • 1
  • 25
  • 22