Re: How can I solve this?

From: Date: Fri, 20 Jan 2006 00:15:58 +0000
Subject: Re: How can I solve this?
References: 1  Groups: php.db 
Request: Send a blank email to php-db+get-41085@lists.php.net to get a copy of this message
Thank you, In fact, its called busy-ness, and I tend to believe I have quite a prowess in the was of Regular Expressions. Reason I have the character class? You betchya! So I could do exactly what your friend did. Reason I completely forgot? I'm an idiot and was too busy replying to 3 emails at once whilst on a phone call. My fault? Completely ;-) Yes, see its called impulsive reasoning, hence the reason I added the character class without needing it, embedding a character class predicate such as \w inside a character class enclosure alone is well.. Stupid and reduntant at best.. Therefore there was some sub-concious reasoning to my madness I can presume. And yes, I also know that that \w class wouldn't cover all the characters I needed in a possible filename, again, I was careless and quick As for the compatibility of the \w character class within sed and awk: I am well aware that this implementation works on Perl-Compatible Regular Expression patterns, and is not a necessarily supported by all regular expression standards BUT WHO GIVES A FLYING FUCK? But this is a PHP-DB list, he is asking a PHP related question and I even specifically stated in my response: preg_replace() which is a PCRE function using the PCRE pattern modifiers. And finally this is a mailing list, not a kindergarten room. We're here to help, assist, and suggest advice. Not to wipe their bottoms. I posted a suggestive solution to a problem. Thats all SURE theres going to be different methods of approaching it, SURE it could not be the most perfect pattern, but its a suggestion where to head for the correct solution. HELL it wouldn't work with .asp files either. Or if your files were named .php4 or .phtml Do I give a damn about that? No. Are you a tech support officer Jeremy? Do you need to help them digest their baby jelly food? Actually, enough of the hostility, I am honoured actually to think you went to the effort of sending off my 10 second quick drafted suggestive PCRE pattern off to Eric Pement of MBI.. Wow, touched. Imagine if I gave you guys some REAL PCRE patterns that I use!!! Now that you'd honour me for wouldn't you! I can just picture you two drooling at the mouth now. So is this Eric friend of yours some RegEx guru? I respect him if so, no harm intended, but I do think my suggestive help posting to this list was 'fit for purpose' He never asked anyone to spoon feed him, and if you want to be a real world developer you better learn to use your resources and reference manuals. I've had enough now. Adios and cya later mate! P.S. You (Jeremy) and Eric are Americans right?? :-) Just curious. ---oOo--- Allowing users to execute CGI scripts in any directory should only be considered if: ... a.. You have no users, and nobody ever visits your server. ... Extracted Quote: Security Tips - Apache HTTP Server ---oOo--- ------oOo---------------oOo------ Julien Bonastre [The_RadiX] The-Spectrum Network CEO ABN: 64 235 749 494 julien@the-spectrum.org www.the-spectrum.org ------oOo---------------oOo------ ----- Original Message ----- From: "Jeremy Peterson" <jeremy.peterson@moody.edu> To: <php-db@lists.php.net> Sent: Friday, January 20, 2006 8:09 AM Subject: Re: [PHP-DB] How can I solve this?
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... :)
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:
        /^\/?(.*)\/\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.php
so in this case, a character set should be used:
        /^\/?(.*)\/[\w~!@#$%^&*+=-]+\.php$/
Keep 'em coming! -- Eric Pement - eric.pement@moody.edu Educational Technical Services, MBI
Jeremy Peterson, MACS Automation Systems Administrator Crowell Library Moody Bible Institute 820 N. LaSalle Drive Chicago, IL, 60610
Email:          jpeterso@moody.edu
Phone: 312.329.8081
Fax:            312.329.8959
-------------------------------------------------------------------------------- No virus found in this incoming message. Checked by AVG Anti-Virus. Version: 7.1.375 / Virus Database: 267.14.21/235 - Release Date: 19/01/2006 -- No virus found in this outgoing message. Checked by AVG Anti-Virus. Version: 7.1.375 / Virus Database: 267.14.21/235 - Release Date: 19/01/2006

« previous php.db (#41085) next »