Re: regular expression help!

From: Date: Thu, 18 Jan 2007 12:49:56 +0000
Subject: Re: regular expression help!
References: 1 2  Groups: php.general 
Request: Send a blank email to php-general+get-247317@lists.php.net to get a copy of this message
Hello Roman, Could you specify the functionality of your script a bit please. (How it works) I forgot to mention that this part: <img width="99" height="120" border="0" src="%s" />', is not always the same. The image properties can vary. Thanks -Will "Roman Neuhauser" <neuhauser@sigpipe.cz> kirjoitti viestissä:20070118122853.GJ16852@dagan.sigpipe.cz... ># kalles@operamail.com / 2007-01-18 12:34:36 +0200: >> I need to strip all characters from the following text string exept the >> image path... >> >> "<img width=\"99\" height=\"120\" border=\"0\" >> src=\"../../images/new/thumps/4123141112007590373240.jpg\" />"...and then >> store the path to DB. Image path lengh can vary so I guess that I need to >> extract all characters after scr=\" until next \" or >> somethig >> similar. > > This passes with 5.2: > > class ImgSrcTest extends Tence_TestCase > { > private $src, $str, $xml; > function setUp() > { > $this->src = 'fubar.jpg'; > $this->str = sprintf( > '<img width="99" height="120" border="0" > src="%s" />', > $this->src > ); > $this->xml = new SimpleXmlElement($this->str); > } > function testReturnsAttributeAsSimpleXMLElements() > { > return $this->assertEquals('SimpleXMLElement', > get_class($this->xml['src'])); > } > function testCastToStringYieldsTheAttributeValue() > { > return $this->assertEquals($this->src, strval($this->xml['src'])); > } > } > > -- > How many Vietnam vets does it take to screw in a light bulb? > You don't know, man. You don't KNOW. > Cause you weren't THERE. > http://bash.org/?255991

« previous php.general (#247317) next »