public final class RegexHelp extends Object
字符简写式 \a 报警符,[\b] 退格字符,\b 单词边界,\B 非单词边界,\cx 控制字符,\d 数字字符,\D 非数字字符,\dxxx 字符的十进制值,\oxxx 字符的八进制值 \s 空白符,\S 非空白符,\w 单词字符,\W 非单词字符,\0 空字符,\x xx 字符的十六进制值,\\u xxxx 字符的Unicode值
posix字符组 [[:ascii:]] ASCII字符(128个) [[:graph:]] 图形字符 [[:print:]] 可打印字符 [[:punct:]] 标点符号 [[:space:]] 空格符号
| 限定符和类型 | 字段和说明 |
|---|---|
static String |
BOOLEAN |
static String |
BYTE |
static String |
CH_PHONE |
static String |
CH_POSTAL_CODE |
static String |
CHAR |
static String |
CHAR_255 |
static String |
DIGITAL |
static String |
DOMAIN |
static String |
EMAIL |
static String |
HTML |
static String |
IP |
static String |
LOGIN_NAME |
static String |
MIDDLE_CH |
static String |
NAME_CH |
static String |
NAME_CH_MINORITY |
static String |
NAME_EN |
static String |
NO |
static String |
PHONE |
static String |
PWD |
static String |
QQ |
static String |
UNSIGNED_BYTE |
static String |
UNSIGNED_DIGITAL |
static String |
URL |
| 限定符和类型 | 方法和说明 |
|---|---|
static String |
find(String s,
boolean all,
int flags,
String... regexes) |
static String |
find(String s,
boolean all,
String... regexes) |
static String |
find(String s,
int flags,
String regex,
int group) |
static String |
find(String s,
String... regexes) |
static String |
find(String s,
String regex) |
static String |
getHost(String url) |
static int |
getIdentityAge(String identity)
获取身份证号年龄
|
static String |
getIdentityBirthday(String identity)
获取身份证号出生日期
|
static String |
getIdentityRegion(String identity)
获取身份证号所在地区
|
static Sex |
getIdentitySex(String identity)
获取身份证号性别
|
static boolean |
isAllMatch(String s,
String... regexes) |
static boolean |
isAllMatch(String s,
String regex1,
String regex2) |
static boolean |
isAnyMatch(String s,
String... regexes) |
static boolean |
isAnyMatch(String s,
String regex1,
String regex2) |
static boolean |
isBirthday(String s) |
static boolean |
isIdentity(String s) |
static boolean |
isMatch(String s,
String regex) |
static boolean |
luneCheck(String s)
判断是否卡号
|
static int |
luneCompute(String s)
计算卡号校验位
|
static boolean |
nonAllMatch(String s,
String... regexes) |
static boolean |
nonAllMatch(String s,
String regex1,
String regex2) |
static boolean |
nonAnyMatch(String s,
String... regexes) |
static boolean |
nonAnyMatch(String s,
String regex1,
String regex2) |
static boolean |
nonMatch(String s,
String regex) |
static String |
replace(String s,
int flags,
String regex,
Function<Matcher,String> func) |
static String |
replace(String s,
String regex,
Function<Matcher,String> func) |
public static String find(String s, int flags, String regex, int group)
flags - 正则表达式中出现了^或者$, 默认只会匹配第一行. 设置了Pattern.MULTILINE模式,会匹配所有行
默认情况下, 正则表达式中点(.)不会匹配换行符, 设置了Pattern.DOTALL模式, 才会匹配所有字符包括换行符public static String replace(String s, int flags, String regex, Function<Matcher,String> func)
public static boolean isBirthday(String s)
public static boolean isIdentity(String s)
public static int getIdentityAge(String identity)
public static boolean luneCheck(String s)
public static int luneCompute(String s)
Copyright © 2022. All rights reserved.