|
@@ -15,6 +15,9 @@
|
|
|
*/
|
|
|
package com.baomidou.mybatisplus.toolkit;
|
|
|
|
|
|
+import java.util.regex.Matcher;
|
|
|
+import java.util.regex.Pattern;
|
|
|
+
|
|
|
/**
|
|
|
* <p>
|
|
|
* String 工具类
|
|
@@ -31,7 +34,9 @@ public class StringUtils {
|
|
|
public static final char UNDERLINE = '_';
|
|
|
|
|
|
/**
|
|
|
+ * <p>
|
|
|
* 判断字符串是否为空
|
|
|
+ * </p>
|
|
|
*
|
|
|
* @param str
|
|
|
* 需要判断字符串
|
|
@@ -42,7 +47,9 @@ public class StringUtils {
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
+ * <p>
|
|
|
* 判断字符串是否不为空
|
|
|
+ * </p>
|
|
|
*
|
|
|
* @param str
|
|
|
* 需要判断字符串
|
|
@@ -78,7 +85,9 @@ public class StringUtils {
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
+ * <p>
|
|
|
* 字符串下划线转驼峰格式
|
|
|
+ * </p>
|
|
|
*
|
|
|
* @param param
|
|
|
* 需要转换的字符串
|
|
@@ -102,4 +111,34 @@ public class StringUtils {
|
|
|
}
|
|
|
return sb.toString();
|
|
|
}
|
|
|
+
|
|
|
+ /**
|
|
|
+ * <p>
|
|
|
+ * 判断字符串是否为纯大写字母
|
|
|
+ * </p>
|
|
|
+ *
|
|
|
+ * @param str
|
|
|
+ * 要匹配的字符串
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ public static boolean isUpperCase(String str) {
|
|
|
+ return match("^[A-Z]+$", str);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * <p>
|
|
|
+ * 正则表达式匹配
|
|
|
+ * </p>
|
|
|
+ *
|
|
|
+ * @param regex
|
|
|
+ * 正则表达式字符串
|
|
|
+ * @param str
|
|
|
+ * 要匹配的字符串
|
|
|
+ * @return 如果str 符合 regex的正则表达式格式,返回true, 否则返回 false;
|
|
|
+ */
|
|
|
+ public static boolean match(String regex, String str) {
|
|
|
+ Pattern pattern = Pattern.compile(regex);
|
|
|
+ Matcher matcher = pattern.matcher(str);
|
|
|
+ return matcher.matches();
|
|
|
+ }
|
|
|
}
|