需求描述: 今天帮同事调整脚本,涉及到判断一个字符串为非空的,在此记录下. 操作过程: 通过-n来判断字符串是否为非空,如果为非空那么就是真 #!/bin/bash Str1='MyTest' if [[ -n $Str1 ]];then echo "$Str1 is not empty." fi 执行结果: [am@hadoop3 scripts]$ sh test.sh MyTest is not empty. 备注:经过测试,字符串不是空,判断是真了. 文档创建时间:2018年4…
public class IsContainChinese { public static boolean isContainChinese (String str){ boolean flag=true; int count = 0; String regEx = "[\\u4e00-\\u9fa5]"; Pattern p = Pattern.compile(regEx); Matcher m = p.matcher(str); while (m.find()) { for (in…