Re: extracting text - regex

From: Date: Wed, 08 Apr 2009 12:30:25 +0000
Subject: Re: extracting text - regex
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-291208@lists.php.net to get a copy of this message
Merlin Morgenstern wrote: > Hello, > > I am trying read text out of a text that is inbetween two divs. > Somehow this should be possible with regex, I just can't figure out > how. > > Example: > > <div id="test"> > bla blub > </div> > > I would like to extract the text "bla blub" out of this example. > This might do the trick (not tested): preg_match( "/<div\s+[^>]*>([^<]*)<\/div>", $yourtext, $match ); print $match[1]; /Per -- Per Jessen, Zürich (16.8°C)

« previous php.general (#291208) next »