ifyalciner
ifyalciner

Reputation: 1258

C++ regex_match match_continuous flag doesn't match beginning sub-string

I had been rumbling with regex_match with the following example

string text("*  @file  my_file.c");
regex exp("\\s*\\*\\s*@file")

if(regex_match(text,exp,regex_constants::match_continuous))
    //This doesn't work

I know that regex_match try to match whole text with regex expression but as far as I read here match_continuous flag supposed to accept sub-strings that start at the beginning of the text. But my luck didn't go well so I had to convert my solution to this

string text("*  @file  my_file.c");
regex exp("^\\s*\\*\\s*@file")

if(regex_search(text,exp))
    //This time works

I would like to ask that what was I doing wrong in the first example. My environment is VS2010.

Upvotes: 3

Views: 1729

Answers (1)

Brice M. Dempsey
Brice M. Dempsey

Reputation: 2161

match_continous works with regex_search.

E.g.

std::regex_search(text, exp, std::regex_constants::match_continuous)

Upvotes: 3

Related Questions