ShaneKm
ShaneKm

Reputation: 21328

RegEx for only 1 URL

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

Answers (2)

Town
Town

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

Related Questions