Or you could regex it with something like this:
ereg("^([^a-zA-Z0-9]*)(.*)$", $inStr, $resultArr);
Then $resultArr[0] will be the original input, $resultArr[1] will be
everything up until an unacceptable character was encountered (not including
the unaccepted character), and the last part would contain the unaccepted
character (first) along with the rest of the input. If you took the substr
for the first character of that, you would be able to say "The character
$bad_char is not allowed" (etc).
My syntax, etc might be a little off, I haven't tested this... but
theoretically it should work.....
Toby Butzon
[ criticism spurs improvement ]
----- Original Message -----
From: "Ignacio Vazquez-Abrams" <[EMAIL PROTECTED]>
To: "Murray Shields" <[EMAIL PROTECTED]>
Cc: <[EMAIL PROTECTED]>
Sent: Tuesday, January 09, 2001 6:41 PM
Subject: Re: [PHP] Baby's First Regex! (Repost - Please Help)
: 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: [EMAIL PROTECTED]
: > 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 <[EMAIL PROTECTED]>
:
:
: --
: PHP General Mailing List (http://www.php.net/)
: To unsubscribe, e-mail: [EMAIL PROTECTED]
: For additional commands, e-mail: [EMAIL PROTECTED]
: To contact the list administrators, e-mail: [EMAIL PROTECTED]
:
:
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]