开发者

Regex to validate url

开发者 https://www.devze.com 2023-04-07 07:36 出处:网络
The url开发者_StackOverflow 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, b

The url开发者_StackOverflow 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.


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

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

But why not just escape it?

0

精彩评论

暂无评论...
验证码 换一张
取 消