0

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

Jason Kealey
  • 7,988
  • 11
  • 42
  • 55
ShaneKm
  • 20,823
  • 43
  • 167
  • 296

2 Answers2

1

See What is the best regular expression to check if a string is a valid URL?

Community
  • 1
  • 1
Jason Kealey
  • 7,988
  • 11
  • 42
  • 55
1

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.

Town
  • 14,706
  • 3
  • 48
  • 72