I have the following BBCode that I needed to parse
[url=http://www.google.com]Google[/url] [url="http://www.google.com"]Google[/url]
What I am trying to do is extract both http://www.google.com and Google
Now the difference between the two pieces of BBCode above is the quotes around the url in the second BBCode.
Is it possible for a single regex code to extract my datapoints and account for the presence or abscense of quotes?
Thanks!
EDIT: Just for further clarification. I am currently using the following Regex pattern:
/\[URL=\"?([\s\S]*?)\"?\]([\s\S]*?)\[\/URL\]/gi
This will successfully match the URL if it is wrapped in quotes or not. However, I would like the final result to be stripped of all quotes. Is this possible via the actual regex pattern itself to simply not include the quotes in the match (if the quotes are even there)
Yes:
will capture
'"'or'';'http://www.google.com'; and'Google'.(I realize you don’t actually need to capture the
'"'or'', but that’s how the regex manages to require that the double-quotes either both be present or both be absent. I also realize that you probably need to cover other link-targets and link-texts besides your example, but I’m assuming that you already know how to handle that, and are just asking about the issue with the optional double-quotes?)