Regex PHP to find BBCode tag contents -
i have string such this:
land of gray [example]here example[/example] , pink.
i'm struggling php/regex code return contents of [example]
tag variable...
i'm not php expert but... regex work
\[example\]([^\[]*)\[
that capture contents in capture group.
so example contents should in $matches[1] ???
ex:
<?php $subject = "land of gray [example]here example[/example] , pink."; $pattern = '/\[example\]([^\[]*)\[/'; preg_match($pattern, $subject, $matches); print_r($matches[1]); ?>
i didn't test code above because don't have php running on machine think work...
Comments
Post a Comment