URL Friendly regular expression

Posted by Caesar on Stack Overflow See other posts from Stack Overflow or by Caesar
Published on 2010-03-19T14:49:55Z Indexed on 2010/03/19 15:01 UTC
Read the original article Hit count: 345

Filed under:

Can anyone help me with regular expression for this: basically I have a search form and users type in whatever keywords they want to search and when a search button is clicked, the search keyword is appended to the url (see examples below). Note the keyword may contain any character.

Example 1 Search key: whatever you want URL: www.example.com/search/whatever+you+want/

Example 2 Search key: oh boy! what's going on? URL: www.example.com/search/oh+boy!+what's+goin+on%3F

What regular expression can I use to capture all characters in the ASCII table between 32 to 126?

© Stack Overflow or respective owner

Related posts about regex