Wednesday, 21 August 2013

How check that string is NOT blank by java regular expression?

How check that string is NOT blank by java regular expression?

There is regular expression for finding blank string and I want only
negotiation. I also see this question but it does not work for java (see
examples). Solution also not work for me (see 3-rd line in example).
For example
Pattern.compile("/^$|\\s+/").matcher(" ").matches() - false
Pattern.compile("/^$|\\s+/").matcher(" a").matches()- false
Pattern.compile("^(?=\\s*\\S).*$").matcher("\t\n a").matches() - false
return false in both cases.
P.S. If something is not clear ask me questions.

No comments:

Post a Comment