Reputation: 3050
"'\[b\](.*?)\[/b\]'is",
Is my current RegEx working. But I want to change the [] to be <> instead. But it doesn't work... What more then just the [] do I need to change.
Upvotes: 0
Views: 613
Reputation: 316999
There are various BBCode parsers available for PHP, for instance
which allows you to simply define your replacement rules by hand:
echo bbcode_parse(
bbcode_create(
array(
'b' => array(
'type' => BBCODE_TYPE_NOARG,
'open_tag' => '<b>',
'close_tag' => '</b>'
)
)
),
'[b]Bold Text[/b]'
);
// prints <b>Bold Text</b>
Also check the various similar questions about BBCode Parsers:
Upvotes: 1
Reputation: 50976
Try ~
as a delimiter instead
preg_match("~<b>(.*?)</b>~is", $text, $b);
Upvotes: 1