This is my problem: http://regexr.com?2temn
I'm sure it's pretty simple for some of you regex masters.
Cheers!
This is my problem: http://regexr.com?2temn
I'm sure it's pretty simple for some of you regex masters.
Cheers!
This also works:
(?<=\.|)\w+\.\w+$
Tested only with PHP.
Regex (generic form) :
/^(?:https?://)?(?:([\w_.-]+?).)*[\w_-]+\.\w+.+$/i
Test :
http://subdomain.domain.tld/foo/bar.html => One match (subdomain) http://subdomain.subdomain2.domain.tld/bar => Two submatches (subdomain, subdomain2) http://justdomain.tld => NO match
Tested with C#.
C# version of the regex :
^(?:http://)?(?:([\w+_.-]+?)\.)*[\w+_-]+\.\w+.+$
Try with:
(\w+\.\w+)[\r\n]+
It matches string with dot inside before new line character
I adjusted your version slightly:
(?:\.|)\w+(\.\w+){1,}
I just made the trailing ".xyz" part be a separate token to loop one or many times ("{1,}
").