I want a regex that can parse ignoring the nested matches
I mean on this for example:
/*asdasdasd /* asdasdsa */ qweqweqwe */
to match the first "/*" with the last "*/" and not stopping to the first "*/"
Thanks...
RegEx expressions will naturally be greedy, so you can just use:
\/\*.*\*\/
If you wanted it to do what you're afraid of and make the RegEx be lazy and stop after the first match you'd have to add an ? like:
\/\*.*?\*\/
Regular expressions can't count nested items by definition (though implementations do go further than the computer scientific definition).
See http://en.wikipedia.org/wiki/Regular_expression#Expressive_power_and_compactness
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