
February 9th, 2003, 09:58 PM
|
|
Junior Member
|
|
Join Date: Feb 2003
Posts: 2
Time spent in forums: < 1 sec
Reputation Power: 0
|
|
|
Regular Expressions
Hey, I'm fairl adept with PHP and recently while trying to install Linux on my laptop i came accross regular expressions!! wow, these are soo cool....or so i hear - a friend pointed me at the tutorial and its great for validating string...but you don't say anyhing on using it in preg_replace() I'm trying to compress my html source into a format where there are no newlines, just any existing spaces before/after > and < so it would look something like this:
<html> <head> <title> This is the Title - Note The Sopace After the title tag </title> </head> </html>
thats the plan anyhow i think the search strig shoudl look something like this:
^(>[[:space:]][[:space:]])
and the replace string something like this:
^(>[[:space:]])
I figure if I only check for "< " (with 2 spaces after the < ) then I won't erase spaces after the tabs like <strong>
eg
welcome to<strong> site name</strong> new user
I'd just like i note on the preg_()/egreg_() differences and a lil' piece on using reg expressions for replacment like that
btw..nice tutorial - ony one thats made ANY sense!!
Last edited by Phod : February 9th, 2003 at 10:08 PM.
|