Page 1 of 1

little problem

Posted: Fri Jan 26, 2007 12:02 am
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.

Posted: Fri Jan 26, 2007 12:33 am
by volka
third thread on the same subject.
Did you take a look at the last suggestions in you first thread?

Posted: Fri Jan 26, 2007 7:58 am
by feyd
eshban, you are now in seriously hot water.