Here is my current regex:
\b\d(?:[^\n\d]*\d){14}(?!\d)
Explanation:
\b
: Matches a word boundary so that first match digit is matched in a separate word[^\n\d]*
: Matches 0 or more of any char that is not a digit and not a line break(?:[^\n\d]*\d){14}
: Matches 14 digits optionally interspersed by 0 or more non-digits, non-line breaks
The problem with this pattern is that it matches various date pattern that should be excluded as shown in this
I need to modify the current regex so that it will not match if it includes a date pattern. Here is the
Now, if I could just figure out how to exclude the second pattern date matches from the first pattern of 15-digit matches. That is what I am trying to accomplish.
Any ideas?
CodePudding user response:
You may try this regex:
\b\d(?!(?:\d{0,3}([-\/\\.])\d{1,2}\1\d{1,4})\b(?!\S))(?:[^\n\d]*\d){14}\b
Here (?!(?:\d{0,3}([-\/\\\.])\d{1,2}\1\d{1,4})\b(?!\S))
is a negative lookahead pattern to avoid including dates in your matches.