regex - Matching non-whitespace in Java -


i detect strings have non-whitespace characters in them. right trying:

!pattern.matches("\\*\\s\\*", city) 

but doesn't seem working. have suggestions? know trim string , test see if equals empty string, rather way

what think regex matches?

try

pattern p = pattern.compile( "\\s" ); matcher m = p.matcher( city ); if( m.find() ) //contains non whitespace 

the find method search partial matches, versus complete match. seems behavior need.


Comments

Popular posts from this blog

c++ - Convert big endian to little endian when reading from a binary file -

C#: Application without a window or taskbar item (background app) that can still use Console.WriteLine() -

unicode - Are email addresses allowed to contain non-alphanumeric characters? -