Reputation: 109
I'm trying to extract the following text in the header of a Response:
Location: example.aspx?X+Gy/a4DwC/og==
With the RegEx Location: (.*)
, I can get this: example.aspx?X+Gy/a4DwC/og==
With the RegEx Location: example.aspx?(.*)
I manage to get this: ?X+Gy/a4DwC/og==
But just I need to extract X+Gy/a4DwC/og==
without the question mark.
Upvotes: 2
Views: 56
Reputation: 43169
You could use the following pattern:
(?<=[?])(?<query>.*)
# Positive lookbehind looking for a question mark
# start a named capturing group called query, this will hold your output
See a demo on regex101.
Upvotes: 0
Reputation: 626936
You may use a lookbehind to say that you need to match all starting after a ?
:
(?<=[?]).*
See regex demo. You may replace *
with +
to match at least 1 symbol. Use $0$
template with this expression.
Another alternative is using a capturing regex [?](.*)
with $1$
template.
Upvotes: 1