|
Posted by Jim Michaels on 10/16/70 11:39
"John Dunlop" <usenet+2004@john.dunlop.name> wrote in message
news:1137011110.230535.227620@g49g2000cwa.googlegroups.com...
> Nel wrote:
>
>> <?PHP
>> $htmlsource = '<img src="pics/hotdog.gif"> text text <img
>> src="pics/silly%20sausage.gif"> ';
>> eregi('(=")(pics/)([0-9a-zA-Z%/ ]+.[a-zA-z]..)(")',$htmlsource,$imagesintext);
Be aware that . matches any character: escape it with a \ if you want a
dot.
Also, the range A-z includes [\]^_` along the way. were you trying for this?
eregi('(=")(pics/)([0-9a-zA-Z_\-%/ ]+\.[jpgifpnJPGIFPN]{3})(")',$htmlsource,$imagesintext);
BTW, you should not allow spaces (%20) in filenames on a web site.
>> ?>
>
> [...]
>
>> What I am trying to do is replace all images in the format
>> ="pics/image.jpg"
>> with "image.jpg" and at the same time make a list of the files image.jpg.
>> The problem is how to pick up ALL the occurances, not just the first???
>
> preg_match_all(). preg_match is described as an alternative to ereg()
> and it stops searching after finding one match, so I assume ereg()
> stops then too.
Try to tinker with preg_grep?
>
> http://www.php.net/manual/en/function.preg-match-all.php
>
>> Also how to use replace to remove the pics/ bit of the string.
>
> Replace them with the zero string. preg_replace().
>
> http://www.php.net/manual/en/function.preg-replace.php
>
> --
> Jock
>
Navigation:
[Reply to this message]
|