
Hello, All! 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? With best regards, Yaroslav Govorunov, E-mail: slov@rsdn.ru http://www.rsdn.ru http://www.isapirewrite.com

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
participants (2)
-
John Maddock
-
Yaroslav Govorunov