I am trying to strip out the contents of all double-quoted phrases in a
string. I tried the following:
preg_match_all( "/(?:\").*?(?:\")/i", $theString, $matches,
PREG_PATTERN_OR DER);
Given the following input string, whose quotes are escaped (slashed):
dogs \"bean bags\" cats \"in quotes\"
I get these two matches:
"bean bags\"
"in quotes\"
As you can see, I'm still capturing the quotes and one, but curiously not
both, of the slashes.
I want to get just the contents of the string inside the slashed
double-quotes, so here are my questions:
1) How can I get just the contents of the string inside the slashed
double-quotes?
2) Why are the double-quotes still being captured despite my use of
non-capturing parentheses?
3) Why did only one of the slashes get captured?
Thanks
string. I tried the following:
preg_match_all( "/(?:\").*?(?:\")/i", $theString, $matches,
PREG_PATTERN_OR DER);
Given the following input string, whose quotes are escaped (slashed):
dogs \"bean bags\" cats \"in quotes\"
I get these two matches:
"bean bags\"
"in quotes\"
As you can see, I'm still capturing the quotes and one, but curiously not
both, of the slashes.
I want to get just the contents of the string inside the slashed
double-quotes, so here are my questions:
1) How can I get just the contents of the string inside the slashed
double-quotes?
2) Why are the double-quotes still being captured despite my use of
non-capturing parentheses?
3) Why did only one of the slashes get captured?
Thanks
Comment