Narek
Narek

Reputation: 39871

boost regex_match vs regex_search

Does regex_search becomes equivalent to regex_match while matching something in a string if my regex pattern has the following form: ^.......$, i.e. if I tell that what is matched should be in start of the string and should end with the end of the string? Or is there any other difference?

Upvotes: 1

Views: 1611

Answers (1)

Tannin
Tannin

Reputation: 508

No, they aren't equivalent, because the $ in regex_search will match the line-end and ^ will match line-start. So in a multi-line string the regex_search would still find sub-matches. I guess adding the flags boost::match_not_eol and boost::match_not_bol would create the regex_match behaviour.

Upvotes: 4

Related Questions