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,898
  • 10
  • 41
  • 53
ShaneKm
  • 19,771
  • 42
  • 153
  • 271

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,898
  • 10
  • 41
  • 53
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,391
  • 3
  • 48
  • 71