RE: [PHP] RegExp Problem

From: Date: Wed, 18 Oct 2000 08:51:54 +0000
Subject: RE: [PHP] RegExp Problem
Groups: php.general 
Request: Send a blank email to php-general+get-20847@lists.php.net to get a copy of this message
the difference? I am not a regex guru, no idea what commas are doing there. as far as I know everything inside [] is taken laterally, so a comma here should mean exactly itself... but I am not too sure about it.. + after an expression means "at least one match". for instance, if the string is empty it wont result true. (you can remove it if you know that the string is not empty) * would mean 0 or more matches, ? to be or not to be... {3} three exactly... these's more... read the article I referred you too.. it's very good to start.. Cheers! -----Original Message----- From: Mukul Sabharwal [mailto:phpguru@yahoo.com] Sent: Wednesday, October 18, 2000 5:45 PM To: Maxim Maletsky; php-general@lists.php.net Subject: RE: [PHP] RegExp Problem Oh..ok... since u know about regexp ... what's the diff between.. [A-Za-z0-9] and [A-Z,a-z,0-9] and why was the + sign there... --- Maxim Maletsky <maxim@japaninc.net> wrote: > the example posted after me is better that mine... > > anyway: > > it sounds like this: if (case insensitive ereg is > not only( from the > beginning (^) [ any of this: from a-z, from 0 to 9 > and _ ] to the end ($) ) > ) > then reject.. > > if(!eregi("^[_a-z0-9]+$", $var)) > echo 'rejected'; > > ====================== > the second one is better since it checks directly if > the string is > [alphanumeric(note that the case doesn't matter at > all)] and there's an _ . > then the string is allowed. > > if (!ereg('^[[:alnum:]_]+$', $str)) > echo 'rejected'; > > > I think you should read this: > http://www.phpbuilder.com/columns/dario19990616.php3 > > > Cheers! > > > -----Original Message----- > From: Mukul Sabharwal [mailto:phpguru@yahoo.com] > Sent: Wednesday, October 18, 2000 5:32 PM > To: Maxim Maletsky > Subject: RE: [PHP] RegExp Problem > > > hi, > > thanks... could you possibly explain this stuff... i > know about ^ and $ ... but why was + there.... > > is this correct also : > > eregi("[^_a-z0-9]", $var); > > thanks. > > > --- Maxim Maletsky <maxim@japaninc.net> wrote: > > if(!eregi("^[_a-z0-9]+$", $var)) > > echo 'rejected'; > > > > Just a scratch... > > > > > > -----Original Message----- > > From: Mukul Sabharwal [mailto:phpguru@yahoo.com] > > Sent: Wednesday, October 18, 2000 5:18 PM > > To: php-general@lists.php.net > > Subject: [PHP] RegExp Problem > > > > > > Hi, > > > > I want to do the following : > > > > a variable with the following values to be > accepted > > ... > > > > if $variable contains > > > > (1) numbers > > (2) underscores > > (3) letters > > > > to be approved and anything else to be > disapproved.. > > how do i do this.... > > > > I would like to use pcre for this (preferably) but > > ereg would also do.... > > > > thanks... > > > > __________________________________________________ > > Do You Yahoo!? > > Yahoo! Messenger - Talk while you surf! It's > FREE. > > http://im.yahoo.com/ > > > > -- > > PHP General Mailing List (http://www.php.net/) > > To unsubscribe, e-mail: > > php-general-unsubscribe@lists.php.net > > For additional commands, e-mail: > > php-general-help@lists.php.net > > To contact the list administrators, e-mail: > > php-list-admin@lists.php.net > > > > > -- > > PHP General Mailing List (http://www.php.net/) > > To unsubscribe, e-mail: > > php-general-unsubscribe@lists.php.net > > For additional commands, e-mail: > > php-general-help@lists.php.net > > To contact the list administrators, e-mail: > php-list-admin@lists.php.net > > > __________________________________________________ > Do You Yahoo!? > Yahoo! Messenger - Talk while you surf! It's FREE. > http://im.yahoo.com/ > > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, e-mail: > php-general-unsubscribe@lists.php.net > For additional commands, e-mail: > php-general-help@lists.php.net > To contact the list administrators, e-mail: php-list-admin@lists.php.net __________________________________________________ Do You Yahoo!? Yahoo! Messenger - Talk while you surf! It's FREE. http://im.yahoo.com/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net For additional commands, e-mail: php-general-help@lists.php.net To contact the list administrators, e-mail: php-list-admin@lists.php.net

« previous php.general (#20847) next »