I need to create a regex that matches any domain that strictly contains (text.com) but not two domain levels deep. For example:
- text.com –> match
- test.text.com –> match
foo.test.text.com will not match as it contains two domain levels past text.com (foo and test) if that makes sense.
So far, I have been able to create a regex that can find any match for one domain level past text.com but it still matches domains it should not. I’m thinking it needs a negative lookahead assertion which I tried but maybe configured incorrectly?
Here is a link to my current regex editor, any help would be greatly appreciated!
Example of how many current regex fails: https://i.stack.imgur.com/LtD9R.png
This regex will match domains ending with text.com and not having more than 1 subdomain:
^from the start of the string
([^.]+?\.)?an optional string group ending with one dot
$end of string