Title |
Test
Find
Query String Regex
|
Expression |
^((?:\?[a-zA-Z0-9_]+\=[a-zA-Z0-9_]+)?(?:\&[a-zA-Z0-9_]+\=[a-zA-Z0-9_]+)*)$ |
Description |
This is a very simple regex that check the query part of a string. That is to say anything after the "?" at the end of an URL. |
Matches |
?key=value | ?key1=value1&key2=value2 |
Non-Matches |
key=value | ?key=value& |
Author |
Rating:
tedcambron
|
Source |
|
Your Rating |
|
Title: Yes, You're Right
Name: Ted Cambron
Date: 2/20/2011 8:14:21 PM
Comment:
You are absolutely right. I said after the "?" and it is not part of the query string. I added it to the expression to be used to check query strings if there is one and needed the "?" in this regex for that purpose. This is technically not part of the query string but the for purposes of checking for one it has to be there.
Title: Bad documentation
Name: Lionel
Date: 10/6/2008 8:07:49 AM
Comment:
It is said "that is to say anything after the ?".
Yes this is the definition of the query string.
But : "matches ?key=value", "non matches key=value"
Well the ? is not part of a query string. You said it before... everything _after_ the ?
So key=value is a correct query string
Have a look at the HTTP POST method. The posted data does not start with a ?