至少有一个非空白 [英] Having at least one-nonwhitespace
本文介绍了至少有一个非空白的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
str
如果括号中至少包含一个非空格,则必须为真:
str
must be true if it has at least one non-whitespace enclosed in the parenthesis:
str = (a)
str = ( as bs)
str = (as e)
如果根本没有空格则为 false
and false if it has non-whitespace at all
str = ( )
我不确定我是否可以做到 +
但这个条件也传递了 0 个非空格.请更正.
Im not sure if i can do that +
but this condition is also passing the 0 non-whitespaces. Correct it please.
/^\([\S+\s*]+\)$\.test(str)/
推荐答案
你可以使用这个:
/^\(.*\S.*\)$/.test(str)
这匹配任何字符,然后是一个非空白字符(这使得它至少有一个非空白字符),然后是任何字符直到结束.
This matches any character, then a non-whitespace character (that makes it at least one non-whitespace character), and then any character till the end.
这篇关于至少有一个非空白的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文