View Full Version : Preg_match
11-30-2006, 02:39 PM
I can not figure out how to preg_match to allow for only
1.character from A-Z regardless of case
2.And to allow for numeric characters as well
3.Not allow whitespace or any other characters
if (preg_match ('[^0-9]',$input))
Any help much appreciated.
your description needs to be more clear, it's a bit ambiguous.
//a single letter or number
//1 or more (letters or numbers)
//a single letter followed by 1 or more numbers
the 'i' in each case tells it to be case-insensitive.
12-01-2006, 08:58 AM
Thanks Gjay for your response.
Your code is great, but its still not taking into consideration any whitespace.
So basicaly it allows user to put space between characters.
hmm preg_match seems to b a programming language on its own *jokes.
12-01-2006, 11:04 AM
if (preg_match ('/^([a-zA-Z0-9]+)$/',$input) == 1 && preg_match('/\s+/',$input) == 0)
preg_match returns "1" if a match is found, "0" if no match is found....
Powered by vBulletin® Version 4.2.2 Copyright © 2016 vBulletin Solutions, Inc. All rights reserved.