re2 does not seem to give correct results for some patterns when compared to pcre

StackOverflow https://stackoverflow.com/questions/18956314

  •  29-06-2022
  •  | 
  •  

Domanda

I was trying to use both pcre and re2 and I came up with the following observation.

When I give the string as

"ab cd"

and the pattern as

"^[^c]"

re2 returns NO MATCH but its actually a match.

That is to say when I type this RE2::FullMatch("ab cd", RE2("^[^c]")) I get FAIL/No Match.

Please let me know if I am going wrong somewhere or what is the problem?

È stato utile?

Soluzione

RE2::FullMatch matches the entire string, like Jerry says.

There are two basic operators: RE2::FullMatch requires the regexp to match the entire input text, and RE2::PartialMatch looks for a match for a substring of the input text, returning the leftmost-longest match in POSIX mode and the same match that Perl would have chosen in Perl mode.

https://code.google.com/p/re2/wiki/CplusplusAPI

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top