Re: Help with regular expresions! [ASAP]
| From: | maatt | Date: | Wed, 25 Jul 2001 13:32:58 +0000 |
| Subject: | Re: Help with regular expresions! [ASAP] | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-59537@lists.php.net to get a copy of this message | ||
$tag_name = "input";
$new_class = "yourclass";
eregi_replace("(<$tag_name)", "\\1 class=\"$yourclass\"",
$yourstring);
will work for simple cases, but isn't going to give you much more power than
just applying a style to the tag iself - 'input { border : 1px }' say). If
the design is consistent, you can usually find longer blocks of unique text
for replacing headers, subheads, etc.
I'd run the scripts over your templates (backup first), not do output
buffering - manually tweaking a couple of exceptions is a hell of a lot
faster than building re's to catch them.
Matt
"Psychosphere2k" <PsychoSphere2K@hotmail.com> wrote in message
news:OE584ZneAzdfTVSxzW20000318c@hotmail.com...
Hi!
I have a fairly large PHP based website.
Unfortuantely, I didn't make extensive use of stylesheets.
I'm hoping for some help with regular expressions matching ( and =
replacing ) some tags.
I use output buffering, so it would be a simple case of adding some =
lines to my
output hanlder.
eg:
replacing < input .... > with < input .... class =3D "something " >
and < body .... > with < body .... class =3D "something_else" >
Some code, with comments would be really great.
Thanks in advance.
Peter Gibson