Reputation: 815
I need some regex or maybe native Rails trick to check if user entered only domain (without "http", "https", "www" and so on. So, this one would be valid:
google.com.ua
And this would be invalid:
Maybe, it can be simplified just to check if string contains only dots and take it like valid one, and if it contains any other characters - block it.
Tell me please what is better to use for such case and what would be regex for it or another decision.
Thanks.
Upvotes: 2
Views: 966
Reputation: 67988
^(?!www\.)[a-zA-Z0-9.-]+$
Try this.See demo.
https://regex101.com/r/wZ0iA3/5
Upvotes: 3