I try to hold this modular, so it can be better maintained and adapted to own requirements./^(?
If you want pure regex then you can just take out the length check.
I think it's a good idea to test the length of the URL though if you really want to determine compliance with the spec. must be set to this var regex = new Reg Exp("^(http[s]?
Assume that this regex will be used for a public URL shortener written in PHP, so URLs like shouldn’t pass (even though they’re technically valid).