Jump to content


Photo

Some regex help, please


  • Please log in to reply
2 replies to this topic

#1 Brandon Jaeger

Brandon Jaeger
  • Members
  • PipPipPip
  • Advanced Member
  • 155 posts
  • LocationPA
  • Age:25

Posted 30 April 2006 - 05:33 AM

Hi, I need to replace anything between <div> tags with nothing ( "" ). What's the regex pattern for this?

Thanks in advance.
PHP is my friend (=

#2 toplay

toplay
  • Staff Alumni
  • Advanced Member
  • 973 posts

Posted 30 April 2006 - 05:42 PM

Use something like this:

$text = preg_replace('/<div>.*?<\/div>/si', '<div></div>', $text);

or this:

$text = preg_replace('/<div>.*?<\/div>/si', '', $text);


depending on what you mean by "nothing".



#3 Brandon Jaeger

Brandon Jaeger
  • Members
  • PipPipPip
  • Advanced Member
  • 155 posts
  • LocationPA
  • Age:25

Posted 01 May 2006 - 06:35 AM

I meant "nothing" as in a blank string.

Thank you :)
PHP is my friend (=




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users