开发者

PHP regular expression preg_replace

开发者 https://www.devze.com 2023-03-30 04:47 出处:网络
I have some text with css style (taken from database, so when I use echo, css show up) and I want to use preg_replace to replace that css (for example with space). I tried to do something like that:

I have some text with css style (taken from database, so when I use echo, css show up) and I want to use preg_replace to replace that css (for example with space). I tried to do something like that:

$some = "<style[\d\D]*>[\d\D]*?</style>" ;
$text = $result['text'];
$a =   preg_replace($some, " " ,$text);

...but its not working: Warning: preg_replace() [function.preg-replace]: Unknown modifier '['

Any idea how to fix that?

Thx for help and let me know if u ne开发者_Go百科ed more info.


Put your regex in delimeters. A slash is often used:

/regex/flags

In your case:

"/<style[\d\D]*>[\d\D]*?<\/style>/"
0

精彩评论

暂无评论...
验证码 换一张
取 消