Regular expression for not empty

后端 未结 7 1238
执笔经年
执笔经年 2020-12-28 18:31

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

7条回答
  •  無奈伤痛
    2020-12-28 19:11

    For testing on non-empty input I use:

    private static final String REGEX_NON_EMPTY = ".*\\S.*"; 
    // any number of whatever character followed by 1 or more non-whitespace chars, followed by any number of whatever character 
    

提交回复
热议问题