Re: Ereg ()

From: Date: Tue, 16 Apr 2002 13:44:15 +0000
Subject: Re: Ereg ()
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-93183@lists.php.net to get a copy of this message
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 (#93183) next »