C ++ 11 Regular Expression Capture Groups by Name

I am converting boost-based regular expressions to C ++ 11 regex. I have a url capture group:

 \s*?=\s*?(("(?<url>.*?)")|('?<url>.*?)')) 

With boost, if you have smatch , you can call match.str("url") to get the capture group by name. With std::smatch I only see indexed subheadings.

How can I access url capture using std :: smatch class?

+6
source share
1 answer

You cannot name a capture group with the C ++ 11 standard. The C ++ 11 regular expression matches ECMAScript syntax. Here is a link that explains it all http://www.cplusplus.com/reference/regex/ECMAScript/ . Although it can be disappointing, if you think about it, a true regular expression will not support it, this is just one more time.

+5
source

Source: https://habr.com/ru/post/946360/


All Articles