How to get from here:
The #quick# brown fox jumps over the #lazy# dog
to here:
The span-tag quick /span-tag brown fox jumps over the span-tag lazy /span-tag dog
?
And sometimes it`s only:
The quick brown fox jumps over the #lazy# dog
so a dynamic solution would be great.
My output right now is only quick
<?php preg_match("/(?<=#).*?(?=#)/", "The #quick# brown fox jumps over the #lazy# dog", $match);
var_dump($match)
?>
Perhaps using
preg_replaceand a simpler pattern would work:Produces