Frustrated by RegEx in PHP
[email protected] ("Chris. Grobmeier") Thu, 05 Jun 2003 14:27:10 +0200
| Newsgroups | php.lang |
|---|---|
| Message-ID | <[email protected]> |
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.