public class MyStringUtils extends Object
| 限定符和类型 | 方法和说明 |
|---|---|
static int |
appearNumber(String srcText,
String findText)
获取指定字符串出现的次数
|
static int |
appearNumberRe(String srcText,
String findText)
获取指定字符串出现的次数(正则表达式)
|
static boolean |
checkEmail(String email)
邮箱地址验证
|
static String |
deleteAllInvisibleCharacters(String str)
删除所有不可见字符
|
static Integer |
getIndex(String old,
String index)
取文本所在位置
|
static String |
getRandom(int length)
生成随机UUID
|
static String |
getRandom(Integer length,
Boolean isUpperCase)
生成随机UUID
|
static String |
getTextByLine(String str,
int line)
获取某行文本
|
static String |
getTextLeft(String old,
String index)
取文本左边
|
static String |
getTextLefts(String old,
String index)
取文本左边(倒找)
|
static int |
getTextLineNum(String str)
获取文本有多少行
|
static String |
getTextMiddle(String old,
String left,
String right)
取出文本中间
|
static String |
getTextMiddles(String old,
String left,
String right)
取出文本中间加强(最右)
|
static String |
getTextRight(String old,
String index)
取文本右边
|
static String |
getTextRights(String old,
String index)
取文本最右边
|
static Map<String,String> |
getUrlParam(String url)
将String类型的Url参数转为Map类型的参数
|
static boolean |
includeChinese(String str)
判断字符串是否包含汉字
|
static boolean |
isChinese(char c)
判定输入的是否是汉字
|
static boolean |
isChinese(String str)
判断字符串是否是汉字
|
static boolean |
isDouble(String str)
判断是否为数字
|
static Boolean |
isEmpty(List list)
已过时。
|
static Boolean |
isEmpty(String text)
判断文本是否是空(对象为空,或者内容为空)
|
static boolean |
isIDNumber(String IDNumber)
判断是否为身份证号码
|
static boolean |
isInteger(String str)
判断是否为整数
|
static Boolean |
isNotEmpty(String text)
判断文本是否是非空(对象为空,或者内容为空)
|
static void |
listDistinct(List list)
对List数组去重(HashSet剔除)
|
static String |
longUrlToShorUrl(String longUrl)
获取短连接
|
static String |
MD5Code32(String str) |
static String |
MD5Encode(String origin,
String charsetname) |
static String |
nameMosaic(String name)
给姓名中间打上*号,超过三位数则只显示第一位和最后一位
|
static String |
phoneMosaic(String phone)
给手机号中间打上*号,保留前面3位后面4位
|
static String |
phoneMosaic(String phone,
Integer front,
Integer back)
给手机号中间打上*号,指定保留前后位数
|
static Integer |
strAddCaseInt(String number1,
Object number2)
将String字符转为Integer类型
|
static String[] |
strArrayDistinct(String[] strArray)
String数组去重
|
static Integer |
strCaseInt(String number)
将String字符转为Integer类型
|
static Long |
strCaseLong(String number)
将String字符转为Long类型
|
static Integer |
strExtractNumber(String str)
从字符串中提取数字
|
static String |
strZeroize(String str,
int places)
将字符串的数字填补为指定长度,若不够则向前填补0,若够,则截取为指定长度
|
static String |
subString(String str,
int length)
截取字符串
|
static String |
subString(String str,
int beginIndex,
int endIndex)
截取字符串
|
static String |
textRetract(String str)
文本缩进去除多余空格
|
public static Integer getIndex(String old, String index)
old - 原文本index - 需要取的字符串public static String getTextRight(String old, String index)
old - 原文本index - 需要定位的字符串public static String getTextRights(String old, String index)
old - 原文本index - 需要定位的字符串public static String getTextLeft(String old, String index)
old - 原文本index - 需要定位的字符串public static String getTextLefts(String old, String index)
old - 原文本index - 需要定位的字符串public static String getTextMiddle(String old, String left, String right)
old - 原文本left - 左边的字符right - 右边的字符public static String getTextMiddles(String old, String left, String right)
old - 原文本left - 左边的字符right - 右边的字符public static Boolean isNotEmpty(String text)
text - 需要判断的文本public static Boolean isEmpty(String text)
text - 需要判断的文本@Deprecated public static Boolean isEmpty(List list)
list - 需要判断的LIST数组public static Integer strCaseInt(String number)
number - 需要转换的数字public static Long strCaseLong(String number)
number - 需要转换的数字public static Integer strAddCaseInt(String number1, Object number2)
number1 - 需要转换的数字number2 - 需要相加的值public static boolean isInteger(String str)
str - 传入的字符串public static String subString(String str, int length)
length - 需要截取多长public static String subString(String str, int beginIndex, int endIndex)
beginIndex - 从那个位置开始endIndex - 从那个位置结束public static boolean isDouble(String str)
str - 传入的字符串public static String deleteAllInvisibleCharacters(String str)
str - 传入的字符串public static void listDistinct(List list)
list - 传入的Listpublic static String[] strArrayDistinct(String[] strArray)
strArray - 传入的String数组public static boolean checkEmail(String email)
email - 需要验证的邮箱地址public static String longUrlToShorUrl(String longUrl)
longUrl - 需要缩短的长链接public static String phoneMosaic(String phone)
phone - 需要脱敏的手机号public static String phoneMosaic(String phone, Integer front, Integer back)
phone - 需要脱敏的手机号public static String nameMosaic(String name)
name - 需要脱敏的姓名public static boolean isChinese(String str)
str - 需要被判断的字符串public static boolean includeChinese(String str)
str - 需要被判断的字符串public static boolean isChinese(char c)
c - 被校验的字符public static Map<String,String> getUrlParam(String url)
url - 需要转换的链接地址public static String getRandom(int length)
public static String getRandom(Integer length, Boolean isUpperCase)
public static boolean isIDNumber(String IDNumber)
IDNumber - 身份证号public static Integer strExtractNumber(String str)
str - 需要被提取的字符串public static String strZeroize(String str, int places)
str - 需要被补充的的字符串public static int getTextLineNum(String str)
str - 需要判断的文本public static String getTextByLine(String str, int line)
str - 被选择的的文本line - 某一行文本public static int appearNumberRe(String srcText, String findText)
srcText - 源字符串findText - 要查找的字符串Copyright © 2020. All rights reserved.