regex - Regular expression library that returns all matches for multiple patterns in one run for C++? -


I'm looking for a regular expression (or some other) library for C ++, which I would like to specify several patterns Will allow, run on a string and return matching locations of all patterns. For example: pattern {"abcd", "abcd"} string {"abcd abce abcd"}

Result: matches ABCD matches: 0-3, 11-14: 5-9 < / P>

Is there any such library address?

I recommend that: Promotion: express

One of the possible solutions:

  string text = "abcd abce abcd"; Constant Const sregex abcd = as_xpr ("abcd"); // static - fast sregex abce = sregex :: compile ("abce") // compiled sregex all = * (keep abcd | keep (abce)); What is smack; If (regex_match (text, what, all)) {smatch :: nested_results_type :: const_iterator begin = what.nested_results (). Begin (); Smatch :: nested_results_type :: const_iterator end = what.nested_results (). End (); (; It! = End; it ++) {if (& gt; regex_id () == abcd.regex_id ()) {// You match the ABCD // - Use it- gt; Start () and it-> end () // or it- & gt; Status () and this- & gt; Length () is in progress; } If (it-> regex_id () == abce.regex_id ()) {// You match abcd ... Continue; }; }  

I think that is not the best solution, you can check "Semantic Action and User-Defined Assurance" in the documentation.


Comments

Popular posts from this blog

c# - ListView onScroll event -

PHP - get image from byte array -

Linux Terminal Problem with Non-Canonical Terminal I/O app -