View Full Version : little problem

01-26-2007, 06:59 AM
I have two regular Expression

$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


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


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.


Please help me in this regard.