Java之正则表达式来判断字符串中是否包含字母

xiaoxiao2021-02-28  68

/** * 使用正则表达式来判断字符串中是否包含字母 * @param str 待检验的字符串 * @return 返回是否包含 * true: 包含字母 ;false 不包含字母 */ public boolean judgeContainsStr(String str) { String regex=".*[a-zA-Z]+.*"; Matcher m=Pattern.compile(regex).matcher(str); return m.matches(); }
转载请注明原文地址: https://www.6miu.com/read-56011.html

最新回复(0)