how can I use regex to match a string like this
3 12 34 56
where, 3 is the number of the following patterns(digits in this case), 12, 34, 56 are the actual digits.
It's easy to use one regex to get the number firstly, then match the string with another regex, but how to use one regex to do it?
tried (\d+)(\s\d+){\1}, but didn't work apparently.
The language is C++11, it could be done with two steps, such as:
-
(\d+)(\s\d+)* to match the number 3 firstly
-
3(\s\d+){3} to match the string again
However, I'm just trying to find a more concise way to do it, if possible. Thanks!
Similar question here, but may not be the same language.
Regex with backreference as repetition count
Aucun commentaire:
Enregistrer un commentaire