I am trying to match a string.
String can contain whitespaces
The string should contain atleast one non-white space character.
I tried,
[^\s]
This is matching all non-white space characters.
Any improvement to the above regex will be helpful
如果问题可以简化为“任何问题,只要有一个非空白字符,那么.*\\S.*
应该起作用。
尝试.*\\S.*
这应该与您所追求的相符
\\S
is equivalent to [^\\s]
. Was that your question?
Update, misread the question.
Try .*\\w.*
as your expression. This will match any string that contains at least a single non-white space. In defining your regex, make sure to escape the backslash, so use ".*\\\\w.*"
as your String.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.