I need a Java regular expression, which checks that the given String is not Empty. However the expression should ingnore if the user has accidentally given whitespace in the
You can also use positive lookahead assertion to assert that the string has atleast one non-whitespace character:
^(?=\s*\S).*$
In Java you need
"^(?=\\s*\\S).*$"