0

How would I change

$output = ereg_replace("<script.*</script>", "", $output);

to preg?

 I tried $output = preg_replace("/<script.*</script>/", "", $output);

Thanks

EDIT: Sorry, messed up formatting

Matt
  • 1,599
  • 3
  • 21
  • 33

1 Answers1

2

If you use / as the delimiter, you must escape every occurence of / within the pattern, or its recocnized as delimiter itself and everthing following will be used as modifiers (which will probably fail).

"/<script.*<\/script>/"

or you make your life easy and just choose a different delimiter. I prefer ~, because it occurs in patterns quite infrequent

"~<script.*</script>~"

Update: See comments for the description, what happens here

"~<script.*</script>~siU"
KingCrunch
  • 128,817
  • 21
  • 151
  • 173
  • @ridgerunner: The question was about the syntax, not the semantic of the pattern. But reflecting the meaning of the pattern you are right of course; Ive added it. – KingCrunch May 04 '11 at 22:37