I am in the process of developing a JavaScript Regex and I am struggling to find the right pattern to match a specific domain. Let me provide an example for better understanding.
I need a regex that can identify any domain that exclusively contains (text.com) without going more than one level deep. For instance:
- text.com --> should be a match
- test.text.com --> should be a match
However, foo.test.text.com should not match as it includes two domain levels beyond text.com (foo and test). I hope that clarifies things.
Although I have managed to come up with a regex that recognizes domains one level past text.com, it still matches some incorrect domains. I believe a negative lookahead assertion is needed, which I attempted but might have misconfigured?
The current regex pattern I am using is:
(?<!\w)(\w+.{1}text\.com)
If you would like to view my current regex editor, please visit this link: https://regex101.com/r/P053fv/1. Any assistance would be highly appreciated!
For reference, here is an illustration of how my existing regex fails: https://i.sstatic.net/LtD9R.png.