Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / February 2007

Tip: Looking for answers? Try searching our database.

newbie: match non numeric non whitespace value

Thread view: 
usgog@yahoo.com - 07 Feb 2007 19:28 GMT
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?
John - 08 Feb 2007 03:30 GMT
> I want to detect whether the java String has any non-numeric and non-
> whitespace char. For example,
[quoted text clipped - 4 lines]
>
> 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.
usgog@yahoo.com - 08 Feb 2007 20:31 GMT
> u...@yahoo.com wrote:
> > I want to detect whether the java String has any non-numeric and non-
[quoted text clipped - 12 lines]
> 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. :)
brian.r.williams@gmail.com - 08 Feb 2007 21:35 GMT
On Feb 8, 2:31 pm, "u...@yahoo.com" <u...@yahoo.com> wrote:

> > u...@yahoo.com wrote:
> > > I want to detect whether the java String has any non-numeric and non-
[quoted text clipped - 17 lines]
>
> - 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?
usgog@yahoo.com - 08 Feb 2007 21:38 GMT
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:
>
[quoted text clipped - 22 lines]
> 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.
Lew - 09 Feb 2007 00:23 GMT
>>>>> I want to detect whether the java String has any non-numeric and non-
>>>>> whitespace char. For example,
[quoted text clipped - 3 lines]
>>>>> " 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


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.