Using \bto bind a string does not work for The quick brown 12345678901234 fox jumped over xx987654321xx, on his second try(limited to non-digits), which does:
(?:^|[^\d])(\d{9})(?:$|[^\d])
(not exciting groups to start / end or without numbers)
demo here
Edit: A simpler "modern" style:
(?:^|\D)(\d{9})(?:$|\D)
Python test (which captures several 9-digit groups):
import re
p=re.compile(r"(?:^|\D)(\d{9})(?:$|\D)")
print(re.findall(p,"The quick brown 12345678901234 fox jumped over 987654321dd, 123456789"))
gives:
['987654321', '123456789']
source
share