Jump to content

Regular Expressions Url Validation


K_Drive

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...