Hi, I am using RegEx in Boost v1.29.0. (?= ) and (?! ) expressions do not seem to work at a certain condition. In the following example, "(?=a)b" should match "b" in "xyzabcdefg", but does not. Similarly, "(?!a)b" should not match "b" in "xyzabcdefg" but it does. Can please let me know what is wrong? Thank you for your reply in advance. Yutaka Emura --------- boost::regex expression; boost::match_resultsstd::string::const_iterator subexp; expression.assign("(?=a)b", boost::regbase::perl); if (boost::regex_search((std::string::const_iterator)"xyzabcdefg", (std::string::const_iterator)"xyzabcdefg" + 10, subexp, expression, boost::match_default)) { { // should go here } else { // goes here } expression.assign("(!=a)b", boost::regbase::perl); if (boost::regex_search((std::string::const_iterator)"xyzabcdefg", (std::string::const_iterator)"xyzabcdefg" + 10, subexp, expression, boost::match_default)) { { // goes here } else { // should go here }
I am using RegEx in Boost v1.29.0. (?= ) and (?! ) expressions do not seem to work at a certain condition.
In the following example, "(?=a)b" should match "b" in "xyzabcdefg", but does not.
Which is correct: (?=a) is a forward lookahead *possitive* assertion, so (?=a)b can never match anything since the next character can't be both an 'a' and a 'b' at the same time!
Similarly, "(?!a)b" should not match "b" in "xyzabcdefg" but it does.
It should match: (?!a) will match anything except 'a' so (?!a)b will match the next 'b' that it finds. John Maddock http://ourworld.compuserve.com/homepages/john_maddock/index.htm
Hi John, It was my mistake. Thank you for clarification! -------------- Yutaka Emura Emurasoft, Inc. http://www.emurasoft.com/ E-mail: yutaka@emurasoft.com -----Original Message----- From: John Maddock [mailto:john_maddock@compuserve.com] Sent: Wednesday, January 01, 2003 3:47 AM To: Boost-Users@yahoogroups.com Subject: Re: [Boost-Users] RegEx: (?= ) and (?! )
I am using RegEx in Boost v1.29.0. (?= ) and (?! ) expressions do not seem to work at a certain condition.
In the following example, "(?=a)b" should match "b" in "xyzabcdefg", but does not.
Which is correct: (?=a) is a forward lookahead *possitive* assertion, so (?=a)b can never match anything since the next character can't be both an 'a' and a 'b' at the same time!
Similarly, "(?!a)b" should not match "b" in "xyzabcdefg" but it does.
It should match: (?!a) will match anything except 'a' so (?!a)b will match the next 'b' that it finds. 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@yahoogroups.com Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/
participants (3)
-
John Maddock
-
Yutaka Emura
-
Yutaka Emura <yutakaï¼ emurasoft.com>