Have a pretty specific Regex I need help building. Some restrictions: can't be multi-line, and uses the Go engine so it can't use negative lookbehinds.
Match any nine digit number surrounded by word boundaries, but not those preceded by a period.
123456789 Should match
123456789 Should match
123456789. Should match
0.123456789 Should not match
.123456789 Should not match
https://regex101.com/r/aAd7nN/1
So far I have \b\d{9}\b
, but as you'll see in the Regex101 example, it doesn't work when there's a preceding period.
Thanks!
You may also use:
(?:^|\n|[^.])\b(\d{9})\b
and grab capture group #1 for your match.
Updated Regex Demo
You could match what you don't want and capture in a group what you want to keep using an alternation |
\.\d{9}\b|\b(\d{9})\b
Regex demo
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