Re: How can I solve this?
| From: | Jeremy Peterson | Date: | Thu, 19 Jan 2006 22:09:44 +0000 |
| Subject: | Re: How can I solve this? | ||
| Groups: | php.db | ||
| Request: | Send a blank email to php-db+get-41079@lists.php.net to get a copy of this message | ||
A friend of mine updated your regular expression... Check it out if your interested.
Jeremy
Dear Jeremy, Thanks for writing! I saw this regular expression and thought you might like it... :)Jeremy Peterson, MACS Automation Systems Administrator Crowell Library Moody Bible Institute 820 N. LaSalle Drive Chicago, IL, 60610preg_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:/^\/?(.*)\/\w+\.php$/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:four-to-go.php page#10.php convert$toDM.phpso in this case, a character set should be used:/^\/?(.*)\/[\w~!@#$%^&*+=-]+\.php$/Keep 'em coming! -- Eric Pement - eric.pement@moody.edu Educational Technical Services, MBI
Email: jpeterso@moody.eduPhone: 312.329.8081
Fax: 312.329.8959