473,394 Members | 1,645 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

how to identify Letter v Number in string

I'm at a pretty early stage of learning php and I'm looking to be able
to examine a string and tell which each character in that string is -
a letter or a number. I've tried php.net but I'm either asking the
wrong questions or I don't understand the answers.
Any help gratefully received.
May 22 '07 #1
4 2144
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

jo*****@hotmail.com wrote:
I'm at a pretty early stage of learning php and I'm looking to be able
to examine a string and tell which each character in that string is -
a letter or a number. I've tried php.net but I'm either asking the
wrong questions or I don't understand the answers.
Any help gratefully received.
ctype_alpha($text); // alphabetic within current locale
ctype_digit($num); // digits 0-9

- --
Edward Z. Yang GnuPG: 0x869C48DA
HTML Purifier <htmlpurifier.org Anti-XSS HTML Filter
[[ 3FA8 E9A9 7385 B691 A6FC B3CB A933 BE7D 869C 48DA ]]
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.6 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFGU0IpqTO+fYacSNoRAmhWAKCCHotagBG4HHOShTm+zN 6CkzxINACfYGKW
2RqstIrlopvptQs00pEsT3k=
=08y1
-----END PGP SIGNATURE-----
May 22 '07 #2
On Tue, 22 May 2007 15:19:05 -0400, "Edward Z. Yang"
<ed*********@thewritingpot.comwrote:
>-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

jo*****@hotmail.com wrote:
>I'm at a pretty early stage of learning php and I'm looking to be able
to examine a string and tell which each character in that string is -
a letter or a number. I've tried php.net but I'm either asking the
wrong questions or I don't understand the answers.
Any help gratefully received.

ctype_alpha($text); // alphabetic within current locale
ctype_digit($num); // digits 0-9
Thank you, that looks like what I wanted. I'll be checking it out
later on this week, but does the ctype_aplha() identify spaces, too?
May 23 '07 #3
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

jo*****@hotmail.com wrote:
Thank you, that looks like what I wanted. I'll be checking it out
later on this week, but does the ctype_aplha() identify spaces, too?
ctype_alpha does not accept spaces.

- --
Edward Z. Yang GnuPG: 0x869C48DA
HTML Purifier <htmlpurifier.org Anti-XSS HTML Filter
[[ 3FA8 E9A9 7385 B691 A6FC B3CB A933 BE7D 869C 48DA ]]
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.6 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFGVLpwqTO+fYacSNoRAtKwAJ94STn300kB/iruGWJ0lrl39SJkkgCeKgIv
l5m3FI7kEuGBkceOSTdTR2Q=
=JryD
-----END PGP SIGNATURE-----
May 23 '07 #4
On Wed, 23 May 2007 18:04:32 -0400, "Edward Z. Yang"
<ed*********@thewritingpot.comwrote:
>-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

jo*****@hotmail.com wrote:
>Thank you, that looks like what I wanted. I'll be checking it out
later on this week, but does the ctype_aplha() identify spaces, too?

ctype_alpha does not accept spaces.
Boo-hoo. But thank you anyway!
May 24 '07 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Dennis | last post by:
If a Window's form contains two textboxes, txtUserName for names and the other txtDimension for mathematical values, how could the program code be set up to identify that only letter character(s)...
2
by: trint | last post by:
I need to know if this string, which will always vary is a letter or a number value AND if it is a letter, to only get the number, which is obviously 7000: string prodID = "us7000"; is Parse,...
13
by: QQ | last post by:
for instance, I read a char from the input and I need to decide whether it is a letter or a number What I am doing is char a; ...... // read a int true = false; if( (a >='0') && (a <='z') true...
3
by: ASP Developer | last post by:
I have a generic list of objects. These objects have a text field that contains a letter for the first character and numbers for the next three. For example, "A001". I need to sort these by...
4
by: darrel | last post by:
I can grab a random number in vb.net like this: Dim RandomClass As New Random Dim RandomNumber As Integer RandomNumber = RandomClass.Next(1, 26) However, what I want is a random number. Short...
4
evilmonkey
by: evilmonkey | last post by:
Is there a way to use index of in java to pull the number of occurrences of every letter in a user defined sentence? I can brute force this but is there a faster more elegant way to achieve the same...
2
by: gazz | last post by:
Hi, Please could someone shed some light on this as I am really struggling to understand how to do this. Given a word entered into a window.prompt EG "forum", how do I create a script to...
9
by: Ulterior | last post by:
Hi, everyone, I have a simple problem, which bothers me for some while. I will try to explain it - There is some string, whith different letters in it. Is it possible to analyse this string...
3
by: majorecono | last post by:
What I'm bad at is the dialog box part. This is the code Ive come up with... if you see a way to improve what im thinkng of.... post it please. Program should.... 1. Ask user to type in a...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.