Problem while using regular expression
Posted: Wed Jan 24, 2007 6:03 am
Hello,
I have facing a problem. Kindly help
I have a Regular expression
I have a php code which reads a html file, then that regular expression searches <img> tag
Becoz according to my requirement i have to change the default path found in <img> tag.
Here is another regular expression
This is used to replace the current path found in an html document.
Suppose, i have an html file, in that html file there are two <img> tags and those have
these paths like
and
My Requirement is to change the path "abc/first_pic.jpg" to "images/first.jpg"
and
"admin/img/picture.jpg" to "images/picture.jpg"
Means in every requirement i use this path i.e. 'images/anypicturefile.jpg'
For that purpose i must change my current regular expression which is
$replace = '<img src=images/'."$1";
Can anybody help me to change this regular expression $replace = '<img src=images/'."$1";
,so that it fullfills the above requirement
I have facing a problem. Kindly help
I have a Regular expression
Code: Select all
$pattern = '!<img src="([^"]+)"!';
Becoz according to my requirement i have to change the default path found in <img> tag.
Here is another regular expression
Code: Select all
$replace = '<img src=images/'."$1";
Suppose, i have an html file, in that html file there are two <img> tags and those have
these paths like
Code: Select all
<img src = "abc/first_pic.jpg">
Code: Select all
<img src = "admin/img/picture.jpg>"
and
"admin/img/picture.jpg" to "images/picture.jpg"
Means in every requirement i use this path i.e. 'images/anypicturefile.jpg'
For that purpose i must change my current regular expression which is
$replace = '<img src=images/'."$1";
Can anybody help me to change this regular expression $replace = '<img src=images/'."$1";
,so that it fullfills the above requirement