little problem

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Locked
eshban
Forum Contributor
Posts: 184
Joined: Mon Sep 05, 2005 1:38 am

little problem

Post by eshban »

I have two regular Expression

Code: Select all

$pattern = '!<img src="([^"]+)"!';

$replace = '<img src=images_test/'.'$1';
Actually i have write a small program which read a HTML file. And locate the all <img> tags in it

To locate the <img> tags, The first regular expresson is used.
And to replace the path found in <img> tag, i used the second regular expression.

which is $replace = '<img src=images_test/'.'$1';

Here see the last part of the expression: '$1'

in it all file paths are saved, which can be found while reading the file.
like it contains

/cleb/picture.jpg
/admin/abc.jpg
/cre/pic3.jpg

This thing creates a little problem for me.

In '$1'I just want filenames, like 'picture.jpg', 'abc.jpg', 'pic3.jpg' instead of the whole path as

/cleb/picture.jpg
/admin/abc.jpg
/cre/pic3.jpg

i use the basename functions in second regular expression and also try my best to got the desired output, but i am failed.

Kindly guide that how can i modify the second regular expression, so that it only contains filenames.

Thanks

Please help me in this regard.
User avatar
volka
DevNet Evangelist
Posts: 8391
Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger

Post by volka »

third thread on the same subject.
Did you take a look at the last suggestions in you first thread?
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

eshban, you are now in seriously hot water.
Locked