For example.
If I have
1234X03.04
I want to capture the 03 and 04
But I don't want 12, 23, 34
I understand:
(?!...)(?<!...)But, I don't know how to combine that into a single regex. Can someone help me out? Cheers.
You can use:
(?<!\d)\d{2}(?!\d)
(?<!\d) - prior char is not a digit\d{2} - exactly two consecutive digits(?!\d) - next char is not a digitHere's a demo of the results in PHP. I think PHP's regex is close to Java's.
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