I have been trying to figure out a regex for this problem for quite some time, but it has not worked out, so I am reaching out for some help. I have created a regex that will capture a particular string of numbers when they appear in an email. The problem is that it also captures this particular string of numbers when they are inside a URL. The URLs are randomly generated, and a great deal of the time, they contain a string of numbers that matches my regex. I've been trying to create a regex that will still capture a particular string of numbers but will ignore that string when it is inside a URL but with no luck. Here is an example of the regex I have been using.
(?:700[0-9][0-9]{7}|81[0-9][0-9][0-9]{5}|9999[0-9]{8})\b
and here is an example of an email that contains that certain string.
mailto: From: Sent: Monday, May 17, 2021 11:42 AM To: 700000000 . If received" Detected: External recipients,
https://test.test.test.outlook.com/?url=bunchofrandomstuffthatdoesnotmatterF&data=sfsfsdagfd4454366474retre45435700000000%7CRegex%randomthingsoiMC4wLjAwnotareallink2luMzIiLCJBTiIjfsdkljafdslflsdkajfljie
The problem is that it is capturing the number in text that makes up the URLs and the number in the mailto line. If possible, I need a regex that captures the string of numbers that meet the criteria of the regex anywhere in the email except for when it is inside of a URL.
I have tried the following
(?:700[0-9][0-9]{7}|81[0-9][0-9][0-9]{5}|9999[0-9]{8})\b(?:(?!https://test.test.test.outlook.com).)
It does not work either. Any ideas?