Opened 14 years ago

Closed 14 years ago

#2518 closed Bugs (invalid)

RegEx with $ anchor not Perl-compatible

Reported by: Chad Martin <chad.e.martin@…> Owned by: John Maddock
Milestone: Boost 1.38.0 Component: regex
Version: Boost 1.37.0 Severity: Problem
Keywords: Cc:

Description

If I try to match a string like "WORD1 WORD2" with boost::regex lastWordCapture("(
w+)$"); in order to capture WORD2, the regex_match fails. If I modify the regex to ".*?(
w+)$", it works fine. The following Perl code captures and prints WORD2 as expected.

$string = "WORD1 WORD2"; if ($string =~ /(\w+)$/){

print "$1\n";

}

Change History (3)

comment:1 by mgoldshteyn@…, 14 years ago

I believe you are confusing regex_match with regex_search, which is what should have been used for the case you tried.

Michael Goldshteyn

comment:2 by Chad Martin <chad.e.martin@…>, 14 years ago

You're right. I was used to the fact that Perl doesn't split those two functions up, and so I didn't expect that in Boost. Now that I understand the difference, my code works fine.

Thanks, Chad Martin

comment:3 by John Maddock, 14 years ago

Resolution: invalid
Status: newclosed
Note: See TracTickets for help on using tickets.