In article <001601c10dc9$e4513780$[EMAIL PROTECTED]>,
 [EMAIL PROTECTED] (Jennifer Arcino Demeterio) wrote:

> i have a script to identify if the input is a combination of letters and 
> numbers 
>  
> if (eregi("[a-zA-Z0-9][0-9]+[a-zA-Z][0-9a-zA-Z]",$fieldvalue)) 
> print "alphanumeric"
> } else {
> not an alphanumeric
> } 
> 
> my problem is, when the string ends with a number, for example hello123, it 
> says "not an alpanumeric" ... it works fine when the number is placed before 
> the letters or in between letters ... why is that? 


Your regex matches a pattern of:

-one alphanumeric
-followed by one or more digits
-followed by one letter
-followed by one alphanumeric

The string "hello123" is failing because it does not match the specified 
pattern.  (If "123hello" or "he123llo" really is passing as you describe, 
re-check your code because that should not be possible given the above 
regex.) 

If you want to know if the entire string consists (from beginning to end) 
of any combination of alphanumeric characters, try:

"^[[:alnum:]]+$"

-- 
CC

-- 
PHP Database 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]

Reply via email to