Jump to content

Regular Expressions Url Validation


K_Drive
 Share

Recommended Posts

I am helping develop a website app. We are running into one small problem with a URL validation for a text field.Here is the validation expression being used:http(s)?://([\w-]+\.)+[\w-]+(/[\w- ./?%&=]*)?It seems to be working fine so far except for one small issue. It cannot handle URLs that have a tilde (~) in them. For example:http://www.taiwanfun.com/central/taichung/...r~Bookstore.htmThe validation says that this is not a valid entry.Does anyone have any suggestions?

Link to comment
Share on other sites

How about adding a tilde to the list of allowed characters in the pattern? There are a few other characters missing, you might want to look over the URL spec or check for other patterns online. Characters like !, #, and + are allowed in various places.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...