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

ruby - When to use an ORM (Sequel, Datamapper, AR, etc.) vs. pure SQL for querying -

php - PHPDoc: @return void necessary? -

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