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

mac2022-06-30  95

/** * 使用正则表达式来判断字符串中是否包含字母 * @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.cnblogs.com/bilaisheng/p/10210981.html

最新回复(0)