I need help creating a regular expression
blah blah blah blah <?= __l(array('key'=>'SOMEVALUE','default'=>'string string string')) ?>blah blah
I want to be able to strip the ‘SOMEVALUE’ and the ‘string string string’
Thanks
In advance
====== ‘This is what I have’ ========
$subject = "Blah blah ja ja blah blah jank junk jonk <?= __l(array('key'=>'KEYKEYKEY','default'=>'I am a monkey sigh\'s')) ?> ldjlsakfdj as;dfj as;flkj a fsd ljaasfd <?= __l(array('key'=>'KEYKEYKEY','default'=>'I am a monkey sigh\'s')) ?> ";
$pattern = '#\_\_l\(array\(\'key\'=>\'(.*)\',\'default\'=>\'(.*)\'\)\)#';
if (preg_match_all($pattern, $subject)) {
print "A match was found.";
} else {
print "A match was not found.";
}
print '<br />';
preg_match_all($pattern, $subject, $matches);
echo '<pre>';
print_r($matches);
echo '</pre>'
Your regex is a bit too complicated, try something like this:
The regex is:
And the replacement is simply the 2nd parameter to
preg_replace().