ridermansb
ridermansb

Reputation: 11059

Regex to validate url

The url will be something like: meusite.com/user/{keyword here}

The user will only enter the key word, then I would a regex to validate word if this does not invalidate the URL, blank spaces, special characters and 5 to 22 characters.

Upvotes: 0

Views: 314

Answers (1)

Ry-
Ry-

Reputation: 224877

You just want to validate the keyword? Something like this should work:

/^[a-zA-Z0-9_\-\.\+]{5,22}$/

But why not just escape it?

Upvotes: 1

Related Questions