Regex in URL Rewriting to match Querystring Parameter Values in any order? -


many url rewriting utilities allow regex matching. need urls matched against couple of main querystring parmeter values no matter order appear in. example let's consider url having 2 key parameters id= , lang= in no specific order, , maybe other non-key params interspersed.

an example url matched key params in order:

maybe interspersed non-key params:

is there regex pattern match against querystring param value in order, or best duplicate rules, or in general should other means?

note: main querystring values captured using brackets i.e. id=(3)&lang=(500) , substituted destination url, that's not focus of question.

i suggest parsing query string dictionary , working there, if want regex, can use alternation+repetition match in order (without inlining possible sequences). python example:

>>> import re >>> p = re.compile(r'(?:[?&](?:abc=([^&]*)|xyz=([^&]*)|[^&]*))+$') >>> p.findall('x?abc=1&jjj=2&xyz=3') [('1', '3')] >>> p.findall('x?abc=1&xyz=3&jjj=2') [('1', '3')] >>> p.findall('x?xyz=3&abc=1&jjj=2') [('1', '3')] 

Comments

Popular posts from this blog

javascript - Enclosure Memory Copies -

php - Replacing tags in braces, even nested tags, with regex -