mercredi 29 avril 2020

Exclude first matched character in regex string [duplicate]

I have some code that manually parses a string for a specific character and then makes a copy of the following characters as long as they are a specific range of characters. This is ideal to replace with regex.

The regex that works is a[0-9]{4} matches this but also includes the first character a. Simply removing the first letter of the resulting string with str.erase(str.begin()) is a no go as the resulting copy to the temporary is 140x slower than the manual parse (over 1 million items)

So I tried to exclude the a from the resulting block. (?<=a)[0-9]{4} works in online regex testers but throws in C++ (gcc 6.3) with an "Invalid special open parenthesis."

What expression will return the result I want in C++?

Aucun commentaire:

Enregistrer un commentaire