Looking for some REGEX help in PHP -
i have string:
[color=gray]a bunch of text.[/color]
and write preg_replace
removes between "[color=gray]"
, "[/color]"
-- if it's possible remove tags well, that's great, otherwise can simple replace afterward.
$str = 'dfgdfg[color=gray]a bunch of text.[/color]dfgdfgdfgfg'; $str1 = preg_replace('/\[color=gray\].*\[\/color\]/',"",$str); echo $str1;
or
if color not gray
$str = 'dfgdfg[color=gray]a bunch of text.[/color]dfgdfgdfgfg'; $str1 = preg_replace('/\[color=\w+\].*\[\/color\]/',"",$str); echo $str1;
php regex
No comments:
Post a Comment