This week's book giveaway is in the Jobs Discussion forum.
We're giving away four copies of Java Interview Guide and have Anthony DePalma on-line!
See this thread for details.
The moose likes Beginning Java and the fly likes validation Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Java Interview Guide this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "validation" Watch "validation" New topic


dale con
Ranch Hand

Joined: Apr 15, 2005
Posts: 93
Hi all

I need to make sure a parameter going through to my method doesn not contains letters.

It's a phone number field so it can contain things like '-' or '+' or '()'etc but it can't contains letters

Can anyone help me write a regex for this

Many thanks
Junilu Lacar

Joined: Feb 26, 2001
Posts: 6529

What have you tried so far?

- Junilu
How to Ask Questions the Smart Way
Megs Maquito
Ranch Hand

Joined: May 18, 2005
Posts: 84
Not sure if this is correct but here goes:

This way if anyone would use a String as parameter i.e. phoneNumber x = new phoneNumber (abc) would result in error as the method requires an integer and not a String.

I'm a Hood Ornament
I agree. Here's the link:
subject: validation
It's not a secret anymore!