Reputation: 4092
I'm attempting to run preg_match to extract the text attribute from the first value in an javascript code.
preg_match('/^\[\[\["(.*)"/i', $data, $matches, PREG_OFFSET_CAPTURE);
from
[[["text to extract"," ...
or
[[["text to extract",[[ ...
matches much text: text to extract",["...
Need onli from [[[" to next ".
Upvotes: 0
Views: 40
Reputation: 995
This Regex should work,
\[\[\["(.*?)"
It is capturing text to extract
from [[["text to extract"," ...
It uses the concept of Group capture
Upvotes: 2
Reputation: 81
Looks like you are almost there. Just adding the comma to the regex:
preg_match('/^\[\[\["(.*)",.*/i', $data, $matches, PREG_OFFSET_CAPTURE);
And now "text to extract" is in $matches[1][0]
Upvotes: 0