GAS v3.1.2版本的 MD5 值为:c77a6621f0cc481a15721546dcb9858c
以下内容为反编译后的 RegexUtils.java 源代码,内容仅作参考
package im.blhtcxatrz.messenger.utils;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
public class RegexUtils {
private static final String urlStr = "(((https|http)?://)?([a-z0-9]+[.])|(www.))\\w+[.|\\/]([a-z0-9]{0,})?[[.]([a-z0-9]{0,})]+((/[\\S&&[^,;一-龥]]+)+)?([.][a-z0-9]{0,}+|/?)";
private static Pattern ptUrl = Pattern.compile(urlStr);
public static boolean firstLetterIsEnglishLetter(CharSequence chars) {
if (chars == null || chars.length() <= 0) {
return false;
}
Pattern compile = Pattern.compile("([a-zA-Z])");
return compile.matcher(chars.charAt(0) + "").matches();
}
public static boolean hasLetterAndNumber(CharSequence str, boolean allowUnderLine) {
boolean hasDigit = false;
boolean hasLetter = false;
for (int i = 0; i < str.length(); i++) {
if (!hasDigit && Character.isDigit(str.charAt(i))) {
hasDigit = true;
}
if (!hasLetter && Character.isLetter(str.charAt(i))) {
hasLetter = true;
}
if (hasDigit && hasLetter) {
break;
}
}
boolean isMatches = Pattern.matches(allowUnderLine ? "^[a-zA-Z0-9_]+$" : "^[a-zA-Z0-9]+$", str);
return hasDigit && hasLetter && isMatches;
}
public static boolean hasLink(String str) {
if (str == null) {
return false;
}
Matcher m = ptUrl.matcher(str);
int count = 0;
while (m.find()) {
count++;
}
return count != 0;
}
}