Regular expression for not empty

后端 未结 7 1263
执笔经年
执笔经年 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:14

    You don't need a regexp for this. This works, is clearer and faster:

    if(myString.trim().length() > 0)
    

提交回复
热议问题