RE: [PHP] regex for html attributes
| From: | WILSON, Nick | Date: | Sun, 08 Oct 2000 23:46:05 +0000 |
| Subject: | RE: [PHP] regex for html attributes | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-19134@lists.php.net to get a copy of this message | ||
preg_replace("'<background\s*=\s*([\"\'])?(?(1) (.*?)\\1 |
([^\s\>]+))'isx","background=\"$my_background\"",$htmltext);
Not tested but play around with it, should be pretty close.
Nick
> -----Original Message-----
> From: peyton maddox [mailto:peyton@x2images.com]
> Sent: Sunday, 8 October 2000 1:44
> To: php-general@lists.php.net
> Subject: [PHP] regex for html attributes
>
>
> I would like to be able to use eregi_replace() to change the
> value of an
> html attribute. Specifically, I want to alter the value of
> background="whatever.jpg". I am trying to do this on plain old html
> files so I cant just put a variable in place of
> "whatever.jpg". Anyway,
> does anyone know of a regular expression that would allow me
> to do that?
> Ideally it would recognize quoted and unquoted attributes. Thanks in
> advance.
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net
> For additional commands, e-mail: php-general-help@lists.php.net
> To contact the list administrators, e-mail:
> php-list-admin@lists.php.net
>
>