• Post Reply Bookmark Topic Watch Topic
  • New Topic

validation

 
dale con
Ranch Hand
Posts: 93
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Marshal
Posts: 10396
124
Android Debian Eclipse IDE IntelliJ IDE Java Linux Mac Spring Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What have you tried so far?

- Junilu
How to Ask Questions the Smart Way
 
Megs Maquito
Ranch Hand
Posts: 84
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
What are you doing? You are supposed to be reading this tiny ad!
the new thread boost feature brings a LOT of attention to your favorite threads
https://coderanch.com/t/674455/Thread-Boost-feature
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!