newbie: match non numeric non whitespace value

U

usgog

I want to detect whether the java String has any non-numeric and non-
whitespace char. For example,
"12 34" returns false
"1234" returns false
"12a3" returns true
" a 12 3" returns true

Can I use [^0-9\\s]? If not, what does it mean?
 
J

John

I want to detect whether the java String has any non-numeric and non-
whitespace char. For example,
"12 34" returns false
"1234" returns false
"12a3" returns true
" a 12 3" returns true

Can I use [^0-9\\s]? If not, what does it mean?

Here, try looking for something in the methods of the String class

http://java.sun.com/j2se/1.5.0/docs/api/java/lang/String.html

I'm thinking you should be able to use the "matches" method to do what
you want if you can figure out the regular expression business.
 
U

usgog

I want to detect whether the java String has any non-numeric and non-
whitespace char. For example,
"12 34" returns false
"1234" returns false
"12a3" returns true
" a 12 3" returns true
Can I use [^0-9\\s]? If not, what does it mean?

Here, try looking for something in the methods of the String class

http://java.sun.com/j2se/1.5.0/docs/api/java/lang/String.html

I'm thinking you should be able to use the "matches" method to do what
you want if you can figure out the regular expression business.

Thanks for the reply. The regular expression business is the thing
that I am asking for help. :)
 
B

brian.r.williams

I want to detect whether the java String has any non-numeric and non-
whitespace char. For example,
"12 34" returns false
"1234" returns false
"12a3" returns true
" a 12 3" returns true
Can I use [^0-9\\s]? If not, what does it mean?
Here, try looking for something in the methods of the String class

I'm thinking you should be able to use the "matches" method to do what
you want if you can figure out the regular expression business.

Thanks for the reply. The regular expression business is the thing
that I am asking for help. :)- Hide quoted text -

- Show quoted text -

So basically you want to know if there are any alpha characters in the
string. So, why not just use ([a-zA-Z]) in the regex expression?
 
U

usgog

(e-mail address removed) wrote:
I want to detect whether the java String has any non-numeric and non-
whitespace char. For example,
"12 34" returns false
"1234" returns false
"12a3" returns true
" a 12 3" returns true
Can I use [^0-9\\s]? If not, what does it mean?
Here, try looking for something in the methods of the String class
http://java.sun.com/j2se/1.5.0/docs/api/java/lang/String.html
I'm thinking you should be able to use the "matches" method to do what
you want if you can figure out the regular expression business.
Thanks for the reply. The regular expression business is the thing
that I am asking for help. :)- Hide quoted text -
- Show quoted text -

So basically you want to know if there are any alpha characters in the
string. So, why not just use ([a-zA-Z]) in the regex expression?

I think [a-zA-Z] won't cover i18n characters.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Staff online

Members online

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,012
Latest member
RoxanneDzm

Latest Threads

Top