In this string:
"<0> <<1>> <2>> <3> <4>"
I want to match all instances of "<\d{1,2}>" except those I have escaped with an extra set of triangle brackets, e.g., I want to match 0,2,3,4 but not 1, e.g.:
"<0> <<1>> <2>> <3> <4>"
I want to do this in one single regular expression but the best I could get is:
(^|[^\<])\<(?<1>\d{1,2})>([^>]|$)
Which will match 0,3,4 but not 2, e.g.:
"<0> <<1>> <2>> <3> <4>"
Does anyone know how this can be done with a single regular expression?
You can also try conditionals:
(?(?<=<)(<\d{1,2}>(?!>))|(<\d{1,2}>))
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With