Re: Ereg ()

From: Date: Tue, 16 Apr 2002 14:13:11 +0000
Subject: Re: Ereg ()
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-93193@lists.php.net to get a copy of this message
On Tuesday, April 16, 2002, at 09:51 AM, DrouetL@ldnegoce.com wrote:
Thanks for this answer. But how can i test if i actually have numbers AND letters ?
preg_match('/([A-Za-z].*[\d]|[\d].*[A-Za-z]/', $string); Untested, but in theory should work.
On Tuesday, April 16, 2002, at 08:49 AM, DrouetL@ldnegoce.com wrote:
I'm new with RegEx and I would like to use them to validate my forms entries submitted to the server. My question is how can I verify with the regex that a string is - at least 7 chars - contains Chars and Nums - may contains some special chars (ex : % ! : ; , )but not in first or last position .
I'm assuming that by Chars you mean uppercase/lowercase letters? Numbers are characters too, I thought. preg_match('/^[A-Za-z0-9][A-Za-z0-9%!:;,]{5,}[A-Za-z0-9]$/', $string); The above regex will only match a string that begins with A-Z or a-z or 0-9, then any number of characters that are in the middle character class, then a final A-Z or a-z or 0-9. I think. Try it out, that's untested. Erik
---- Erik Price Web Developer Temp Media Lab, H.H. Brown pricee@hhbrown.com


« previous php.general (#93193) next »