You can use a negative predictive statement to exclude 41 :
/\b(?!41\b)\d+\b/
This regular expression should be interpreted as: on any boundary of the word \b , if it is not followed by 41\b ( (?!41\b) ), match one or more digits followed by the boundary of the word.
Or the same with a negative look-behind expression:
/\b\d+\b(?<!\b41)/
This regular expression should be interpreted as: match one or more numbers that are surrounded by word boundaries, but only if the substring at the end of the match is not preceded by \b41 ( (?<!\b41) ).
Or it may even use only the basic syntax:
/\b(\d|[0-35-9]\d|\d[02-9]|\d{3,})\b/
This corresponds only to sequences of numbers surrounded by word boundaries:
- one digit
- two digits not having
4 in the first position or not 1 in the second position - three or more digits
Gumbo source share