Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > newbie: match non numeric non whitespace value

Reply
Thread Tools

newbie: match non numeric non whitespace value

 
 
usgog@yahoo.com
Guest
Posts: n/a
 
      02-07-2007
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?

 
Reply With Quote
 
 
 
 
John
Guest
Posts: n/a
 
      02-08-2007
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/...ng/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.
 
Reply With Quote
 
 
 
 
usgog@yahoo.com
Guest
Posts: n/a
 
      02-08-2007
On Feb 7, 7:30 pm, John <printdude1...@gmail.com> wrote:
> u...@yahoo.com 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/...ng/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.

 
Reply With Quote
 
brian.r.williams@gmail.com
Guest
Posts: n/a
 
      02-08-2007
On Feb 8, 2:31 pm, "u...@yahoo.com" <u...@yahoo.com> wrote:
> On Feb 7, 7:30 pm, John <printdude1...@gmail.com> wrote:
>
>
>
>
>
> > u...@yahoo.com 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/...ng/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?

 
Reply With Quote
 
usgog@yahoo.com
Guest
Posts: n/a
 
      02-08-2007
On Feb 8, 1:35 pm, "brian.r.willi...@gmail.com"
<brian.r.willi...@gmail.com> wrote:
> On Feb 8, 2:31 pm, "u...@yahoo.com" <u...@yahoo.com> wrote:
>
>
>
> > On Feb 7, 7:30 pm, John <printdude1...@gmail.com> wrote:

>
> > > u...@yahoo.com 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/...ng/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.

 
Reply With Quote
 
Lew
Guest
Posts: n/a
 
      02-09-2007
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?


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


Try "\\p{L}". Read
<http://java.sun.com/javase/6/docs/api/java/util/regex/Pattern.html>

Study it.

- Lew
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: Splitting text at whitespace but keeping the whitespace in thereturned list MRAB Python 3 01-26-2010 11:36 PM
Structure using whitespace vs logical whitespace cmdrrickhunter@yaho.com Python 10 12-16-2008 03:51 PM
Arithmetic overflow error converting numeric to data type numeric. darrel ASP .Net 4 07-19-2007 09:57 PM
check if string contains numeric, and check string length of numeric value ief@specialfruit.be C++ 5 06-30-2005 01:08 PM
Whitespace where I don't want whitespace! Oli Filth HTML 9 01-17-2005 08:47 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57