logo       

Re: [Regex] Maybe bug?: msg#00236

lib.boost.user

Subject: Re: [Regex] Maybe bug?

> For example consider expression:
> (www\.)?(.+?)\.com
> When using match algorithm and try to match "www.somesite.com" $1 gets
"www.somesite" but I thought it should be "somesite". Why (www\.)? is
>ignored even when non greedy repeats are used?

Works just fine for me, using the test code below:

#include <iostream>
#include "boost/regex.hpp"

int main(int, char**) {
boost::regex abc("(www\\.)?(.+?)\\.com");
std::string s("www.somesite.com");
boost::smatch what;
boost::regex_match(s, what, abc);
std::cout << (std::string)what[0] << std::endl
<< (std::string)what[1] << std::endl
<< (std::string)what[2] << std::endl;
return 0;
}

John Maddock
http://ourworld.compuserve.com/homepages/john_maddock/index.htm



Info: <http://www.boost.org>
Wiki: <http://www.crystalclearsoftware.com/cgi-bin/boost_wiki/wiki.pl>
Unsubscribe: <mailto:boost-users-unsubscribe@xxxxxxxxxxxxxxx>


Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/





<Prev in Thread] Current Thread [Next in Thread>
Google Custom Search

News | FAQ | advertise