I'm trying to write a regular expression which returns a string after a particular string.
For example: The string is
"<https://meraki/api/v1/sm/devices?fields[]=imei,iccid,lastConnected,ownerEmail, ownerUsername,phoneNumber&perPage=1000&startingAfter=0>; rel=first"
result I'm expecting is -- first
.
Here is the expression i'm using
(?<=rel=\s").*(?=\)
CodePudding user response:
Okay so this should work:
(?<=rel[=])[^"]*
I would advise looking over the syntax of regex again, because yours was not even matching the colons correctly. Look behinds (?<=pattern)
match before the pattern you want to capture. Likewise look aheads (?=pattern)
match after the pattern.
You can test your regex online here (or many other sites). They will show you the matching groups and errors, but will also explain what certain parts of the pattern do.