Re: Baby's First Regex! (Repost - Please Help)

From: Date: Tue, 09 Jan 2001 23:41:07 +0000
Subject: Re: Baby's First Regex! (Repost - Please Help)
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-33589@lists.php.net to get a copy of this message
On Wed, 10 Jan 2001, Murray Shields wrote: > Hi all. > > I have written my first regex's, which are simply used for validation of > input into a web form. Basically, they check to see if an invalid characters > are being entered, and is working perfectly. A different regex is used to > different types of input. > > They are as follows > > $Status = (ereg("^[A-Za-z0-9` !@#$%&()=:;\"\'.?/-]*$", $String)); > $Status = (ereg("^[0-9 +-]*$", $String)); 0-9 [SPACE] + - > $Status = (ereg("^[A-Za-z' -]*$", $String)); A-Z a-z > - ' [SPACE] > $Status = (ereg("^[A-Z_]*$", $String)); A-Z _ > $Status = (ereg("^[A-Z ]*$", $String)); A-Z [SPACE] > $Status = (ereg("^[0-9 ]*$", $String)); 0-9 [SPACE] > $Status = (ereg("^[A-Za-z0-9` @#$%&()=:;\"\'.?/-]*$", $String)); > > At the moment, the error message sent to the browser is along the lines of > "You have entered invalid characters. Please check and try again." However, > I would rather be able to tell them WHICH characters they entered represent > a problem. > > How can I get a the list of characters tht causes one of these regex's to > fail? > > ====================================================================== > Murray Shields Email: murray@globalcat.com.au > MU Systems Pty Ltd Phone: +61 7 3351 6677 > Global Catalogs Pty Ltd Phone: +61 7 3351 4777 > Proably the only way to do this would be to write a custom parser. REs are amazing for showing you what they found, but are pathetic at showing you what they missed. -- Ignacio Vazquez-Abrams <ignacio@openservices.net>

« previous php.general (#33589) next »