I have the below regex which follows the following rules,
(?<!x)(?=(?:[._ –-]*\d){9})\d{2,}[._ –-]*\d{2,}[._ –-]*\d{2,}
Rules:
- 9 digit Order numbers should not get detected if 'X or x' precedes the number. (WORKING FINE)
- 9 digit numbers, Non-numeric characters or whitespaces (up to 3) in between numbers should also get matched. (WORKING FINE)
Below is regex demo which shows it matches the numbers with the above rules.
https://regex101.com/r/mrGcvp/1
Now, the regex pattern should not match the 9 digit numbers following the above rules if it comes under the below rules of exclusion.
Rules of exclusion,
The number should not be matched at all for the following rules.
- If the number beginning with the number “9”
- If the number “666” in positions 1 – 3.
- If the number “000” in positions 1 – 3.
- If the number “00” in positions 4 – 5.
- if the number “0000” in positions 6 – 9