CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: Regular Expressions:
numbers only

 



user123
New User

May 6, 2010, 12:00 PM

Post #1 of 4 (3879 views)
numbers only Can't Post

Hello,

I've a short question about numbers ...

how can I check with regex if a inputed text contains ONLY numbers ??? (if there's any other thing except a number it should recognize this)

hope someone can help :-)


rovf
Veteran

May 7, 2010, 1:06 AM

Post #2 of 4 (3865 views)
Re: [user123] numbers only [In reply to] Can't Post

Do you mean "wheather it contains only digits" or "whether it is a syntactically valid number"?


user123
New User

May 7, 2010, 2:29 AM

Post #3 of 4 (3863 views)
Re: [rovf] numbers only [In reply to] Can't Post

"wheather it contains only digits"
so only 0123456789 should be valid
23.5; abc123; 1a1; ... -> not valid
only 13412 (e.g.) -> valid


rovf
Veteran

May 7, 2010, 3:52 AM

Post #4 of 4 (3860 views)
Re: [user123] numbers only [In reply to] Can't Post

either

^\d*$

or

^\d+$

depending on what you want to do with the empty string.

 
 


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives