A friend of mine updated your regular expression... Check it out if your interested.


Dear Jeremy,

Thanks for writing!

> I saw this regular expression and thought you might like it... :)

> >preg_replace("/^\/?(.*)\/[\w]+\.php$/","$1",$PHP_SELF)
> >
> >that strips that leading forward slash too ;-)

  \w is a PCRE (Perl-Compatible Regular Expression) that matches any
word character: a-z, A-Z, 0-9 and the underscore "_". sed and awk do
not support \w, although ssed (super-sed) supports \w if an -R switch
is added on the command line.

   Back to PHP and \w : Putting \w by itself inside a character class
"[...]" does absolutely nothing, just as "[a]" and "[9]" does nothing
special. It could be more efficiently written as:


   One additional problem is that the characters defined by \w does
not include the hyphen, the pound sign, or other punctuation marks
that sometimes find their way into filenames, like:


so in this case, a character set should be used:

        /^\/?(.*)\/[EMAIL PROTECTED]&*+=-]+\.php$/

Keep 'em coming!

Educational Technical Services, MBI

Jeremy Peterson, MACS
Automation Systems Administrator
Crowell Library
Moody Bible Institute
820 N. LaSalle Drive
Chicago, IL, 60610

Email:          [EMAIL PROTECTED]
Phone:  312.329.8081
Fax:            312.329.8959

Reply via email to