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
It's faster to create a method for this rather than using regular expression
/**
* This method takes String as parameter
* and checks if it is null or empty.
*
* @param value - The value that will get checked.
* Returns the value of "".equals(value).
* This is also trimmed, so that " " returns true
* @return - true if object is null or empty
*/
public static boolean empty(String value) {
if(value == null)
return true;
return "".equals(value.trim());
}