Frustrated by RegEx in PHP
| From: | Chris. Grobmeier | Date: | Thu, 05 Jun 2003 12:27:10 +0000 |
| Subject: | Frustrated by RegEx in PHP | ||
| Groups: | php.lang | ||
| Request: | Send a blank email to php-lang+get-493@lists.php.net to get a copy of this message | ||
Hello all,
sorry to disturb you with this-
but i am not really good in regex and can't catch it...
I have to parse a html document, and want to replace a piece of this link:
<IMG ID="Bild4" height=30 width=209 SRC="./assets/images/Werbung_oben_header.gif" VSPACE=0 HSPACE=0 ALIGN="TOP" BORDER=0 ALT="">
It shall be:
<IMG ID="Bild4" height=30 width=209 SRC="./nts/templates/images/assets/images/Werbung_oben_header.gif" VSPACE=0 HSPACE=0 ALIGN="TOP" BORDER=0 ALT="">
My regex expression must not care about case sensitiv, should start it's
work when it finds a <img and stop when the > is coming- so that it is
guaranted that only image-src's will be changed.
The ./ before some Pathes must be cutted of and replaced with my path.
Of course, when ./ is not written by the designer it must match too.
And, when for example attributes are in total lack of order, the regex must accept this :)
I have allready started, but nothing of my helpless trys works.
$tpl_source = preg_replace( "=<img\s.+src\=\"(\.)/.+\"\s.+", $url, $html);
$html is my html-document, the $url my extension.
I this possible? Could someone help me plese?
This would be really great!
So, thanks for reading this!
Have a nice day,
Chris.