Reluctant quantifiers can be very useful. However, I can't think of any use of ??, the reluctant version of ?. Can somebody give me an example, or is it just there because the other quantifiers have reluctant versions too?
Here’s an example regular expression that uses the ?? quantifier:
(?:\w+-??|-\w+)
It matches every word that’s either followed by a hyphen or preceeded by a hyphen. In foo-bar it would then match foo and -bar rather than foo- and bar as (?:\w+-?|-\w+) would.
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