[Boost-bugs] [Boost C++ Libraries] #6493: Problem in using regex to find nested tags

Subject: [Boost-bugs] [Boost C++ Libraries] #6493: Problem in using regex to find nested tags
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2012-01-30 02:10:57


#6493: Problem in using regex to find nested tags
----------------------------------+-----------------------------------------
 Reporter: little_bird@… | Owner: johnmaddock
     Type: Bugs | Status: new
Milestone: To Be Determined | Component: regex
  Version: Boost 1.48.0 | Severity: Problem
 Keywords: regex |
----------------------------------+-----------------------------------------
 I want to use regex to find all `"<NPC></NPC>"` like tags in a text file,
 and tags may recursive. So I made an example, using patterns


 `<(?<HtmlTag>NPC)>((?<Nested><\k<HtmlTag>>)|</\k<HtmlTag>>(?<-Nested>)|.*?)*</\k<HtmlTag>>`


 to search string


 `abc<NPC><NPC>12345</NPC>1</NPC>2<NPC>3</NPC>`


 Well, it works well in Expresso(a cool tool in making and testing regular
 expressions, can be found at `http://www.ultrapico.com/`). But by using
 boost::regex_search, it returns the whole string. It seems that the 3rd
 `"<NPC>"` matches `".*?"` but `"</\k<HtmlTag>>"`.

-- 
Ticket URL: <https://svn.boost.org/trac/boost/ticket/6493>
Boost C++ Libraries <http://www.boost.org/>
Boost provides free peer-reviewed portable C++ source libraries.

This archive was generated by hypermail 2.1.7 : 2017-02-16 18:50:08 UTC