I have this hostname regex that I’d like to expand on a bit. It will match hostnames such as:
yahoo.com
mail.yahoo.com
but will also match
&^%yahoo.com
etc…
(\w+\.\w+\.\w+)
Can someone tell me what I need to add to only allow letters, numbers and periods?
Try using
[a-zA-Z0-9\.]+instead of\w+.So all in all this will be: