Parsing a Dynamic URI ?
Here is the problem, depending on the client my URI changes order of the fields.
Format 1: /foo?someId=s1234&nut=bang&baz=bar
Format 2: /foo?nut=bang&baz=bar&someId=s1234
Format 3: /foo?nut=bang&someId=s1234&baz=bar
But I still need to be able to extract "someID". I cant use a regex because the location changes depending on the client. More complicated is the fact that we might have other params that might hit on a wildcard pattern match - like "handsomeId" so I need to either indicate that it's the first param ("?someId=") or that it comes later in query string ("?foo=bar&someId=x") because "*someId=*" would match "handsomeId=" as well. I can write a search for each partner but I'd like to be able to somehow combine the results of all those streams into a single statement. Is there a way to combine multiple regexs into one query and with each regex using the same columns ?
-
You can try using an "or" condition as part of your regex anchors. ie. "?someId=" or "&someId="
parse regex "(?:&|\?)someId=(?<someId>.{5})"
If you need to trigger on the page in the URI you can expand the expression to capture more.
parse regex "\/foo.*(?:&|\?)someId=(?<someId>.{5})"
Please sign in to leave a comment.
Comments
1 comment