Reputation: 21328
please help with regex for only 1 url. Meaning, user is not suppose to be able to supply two urls seperated by comma or other seperator. is that possible? what's the best solution? thanks
Upvotes: 0
Views: 294
Reputation: 14906
There are plenty here: http://www.regexlib.com/Search.aspx?k=url&c=-1&m=5&ps=20
Ensure you add ^ at the beginning to denote the start of the string, and $ to denote the end.
If you only need a single URL, then any other URLs the user adds would make the entire string an invalid URL, so you win.
Upvotes: 1
Reputation: 7986
See What is the best regular expression to check if a string is a valid URL?
Upvotes: 1