I'm trying to extract the domain.com
from an input that can be in the following formats and structure:
1.x.x.domain.com
2.x.domain.com
Once I am getting user's email, for example:
user@x.x.domain.com
I am able to remove the first part of the email address:
user@
by the following regex:
/^.+@/
I want to be able by using the regex over the 2 formats to get the domain.com
right away and not manipulate the input several times until getting the domain.
I thought maybe to count the number of dots from the input and then to do some logic, but it looks so complex for this small solution.
Thanks!