Page 1 of 1

need to find how many chars are alphabetic in the string

Posted: Tue Jun 16, 2009 3:16 am
by lokesh_kumar_s
i want to find how many characters are alphabets in the string the string contains integer also. i want to find no. of integer also. tell me how can i decide if a char is alphabet or integer in the string.

thanks,
lokesh

Re: need to find how many chars are alphabetic in the string

Posted: Tue Jun 16, 2009 3:34 am
by Christopher
You should read through the manual:

http://us.php.net/manual/en/refs.basic.vartype.php

Specifically:
http://us.php.net/manual/en/ref.var.php

And try the search in the manual. For example, search for "integer".

Re: need to find how many chars are alphabetic in the string

Posted: Tue Jun 16, 2009 6:05 am
by lokesh_kumar_s
arborint wrote:You should read through the manual:

http://us.php.net/manual/en/refs.basic.vartype.php

Specifically:
http://us.php.net/manual/en/ref.var.php

And try the search in the manual. For example, search for "integer".
see i am using
and $MaxBarcode is CCEFFD3456740001
preg_match("/([0-9]*)/",$MaxBarcode,$match);

i want to extract 3456740001 but this preg_match("/([0-9]*)/",$MaxBarcode,$match); is not getting me that but preg_match("/([0-9]*$)/",$MaxBarcode,$match); it is getting me 3456740001 why and i know '$' represents "ends with" but preg_match is supposed to match whole $MaxBarcode right?

Re: need to find how many chars are alphabetic in the string

Posted: Tue Jun 16, 2009 6:37 am
by Mark Baker
+ not *
preg_match('/\d+/',$MaxBarcode,$match);