Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

c++

regex

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.

like image 236
ifyalciner Avatar asked Feb 13 '26 05:02

ifyalciner


1 Answers

match_continous works with regex_search.

E.g.

std::regex_search(text, exp, std::regex_constants::match_continuous)
like image 143
Brice M. Dempsey Avatar answered Feb 14 '26 19:02

Brice M. Dempsey



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!