0

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 need more info.

1
  • Try /<style[^>]*>[^<]*<\/style>/i. Commented Aug 23, 2011 at 8:35

1 Answer 1

3

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

/regex/flags

In your case:

"/<style[\d\D]*>[\d\D]*?<\/style>/"
Sign up to request clarification or add additional context in comments.

1 Comment

When dealing with HTML (!), it's often better to pick a different delimiter to avoid having to escape all those slashes.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.