I've created a regex that matches this the URL below but now I want to match the whole URL, capture it in a named group and capture the uid of the URL in another named group.
The example:
<"http://www.accounts.com/support/uid=swg1PM80378">
The expected outcome:
first group: http://www.accounts.com/support/uid=swg1PM80378
second group: swg1PM80378
My regex so far:
<"(?<link>.*(?<id>NOTHING IN HERE YET))">
With this regex I can match the whole URL and capture it in the named group but I want to expand the regex's functionality to also capture the uid of the link and capture it in the second group named
I've used the site https://regexr.com/ to create the regex, maybe it'll be of help.
CodePudding user response:
Try:
\"(?P<link>.*(?P<id>(?<=uid=).*))\"
\"
- match "
(?P<link>.*)
- Match any number of characters into named grouplink
(?P<id>(?<=uid=).*)
- Match any number of characters preceded witchuid=
into named grouplink
\"
- match"