Creating a regex expression for a target URL

Viewed 25

I'm trying to create a regex expression which creates validation for a target Url. Below are the rules I would like to include:

  • must begin with http:// or https://
  • path name must be between 1-63 characters
  • no upper case characters allowed
  • no spaces
  • can only contain the following symbols "-", ".", "_", "~"

e.g. https://www.sdsdsd-sdddf-manage.co.uk/news-and-events/news

This is what I have so far:

^((http://|https://))[a-z0-9._~-]{1,63}[.][a-z{2,6}]$

Thanks!

0 Answers
Related