I have an expression which matches the question mark in a url query string and I find myself needing to extend the expression to accommodate for a case where the URL I am trying to read contains the unicode equivalent of the question mark %3d
the expression is
var regexS = "[\\?&]" + name + "=([^&#]*)";
From what very little I know of RegEx I thought this might work
var regexS = "[\\?&]|[\\%3d&]" + name + "=([^&#]*)";
Thanks for the help
Assuming Javascript for the purposes of string escaping.
In
"[\\?&]|[\\%3d&]" + name + "=([^&#]*)"note thatabc) has priority over alternation (a|b|c) and[\\%3d&]means “percent or 3 or d or ampersand” (character class).?is %3F, not %3D. %3D means=. See wikipedia: percent encoding&q2=inwww.example.com?q1=v1&q2=v2. Perhaps you want to allow escaped ampersand as well. Its escaped form is %26You probably mean
"([\\?&]|\\%3f|\\%26)" + name + "=([^&#]*)"instead.Also note that
?has no special meaning inside a character class and doesn’t need to be escaped:"([?&]|%3f|%26)" + name + "=([^&#]*)"