public class RegExUtils
extends org.apache.commons.lang3.RegExUtils
| 限定符和类型 | 方法和说明 |
|---|---|
static boolean |
containsHanZi(String source)
是否包含汉字
|
static Matcher |
getMatcher(String text,
String regex)
获取 Matcher 对象
|
static Matcher |
getMatcher(String text,
String regex,
int flags)
获取 Matcher 对象
|
static int |
indexOf(String text,
String regex)
获取下标
|
static int |
indexOf(String text,
String regex,
int flags)
获取下标
|
static boolean |
isMatch(String text,
String regex)
是否能匹配
|
static boolean |
isMatch(String text,
String regex,
int flags)
是否能匹配
|
static String |
match(String text,
String regex,
int item)
获取指定匹配项的全部匹配值
|
static String |
match(String text,
String regex,
int item,
int group)
获取指定匹配项的指定捕获组的匹配值
|
static String |
match(String text,
String regex,
int item,
int group,
int flags)
获取指定匹配项的指定捕获组的匹配值
|
static List<String> |
matches(String text,
String regex)
获取匹配集合
|
static List<String> |
matches(String text,
String regex,
int group)
获取匹配集合
|
static List<String> |
matches(String text,
String regex,
int group,
int flags)
获取匹配集合
|
static String |
matchFirst(String text,
String regex)
获取第一个匹配项的所有捕获组的匹配值
|
static String |
matchFirst(String text,
String regex,
int group)
获取第一个匹配项的指定捕获组的匹配值
|
static String |
matchFirst(String text,
String regex,
int group,
int flags)
获取第一个匹配项的指定捕获组的匹配值
|
static String |
replace(String text,
String regex,
String replacement,
int item)
替换指定匹配项的所有捕获组的匹配值
|
static String |
replace(String text,
String regex,
String replacement,
int item,
int flags)
替换指定匹配项的所有捕获组的匹配值
|
static String |
replace(String text,
String regex,
String replacement,
int item,
int group,
int flags)
替换所有匹配项的指定捕获组的匹配值
|
static String |
replaceAll(String text,
String regex,
String replacement,
int group)
替换所有匹配项的指定捕获组的匹配值
|
static String |
replaceAll(String text,
String regex,
String replacement,
int group,
int flags)
替换所有匹配项的指定捕获组的匹配值
|
static String |
replaceAllSpecialChar(String source)
替换特殊字符
|
static String |
replaceFirst(String text,
String regex,
String replacement)
替换第一个匹配项的所有捕获组的匹配值
|
static String |
replaceFirst(String text,
String regex,
String replacement,
int group)
替换第一个匹配项的指定捕获组的匹配值
|
static String |
replaceFirst(String text,
String regex,
String replacement,
int group,
int flags)
替换第一个匹配项的指定捕获组的匹配值
|
public static String replaceAllSpecialChar(String source)
source - 需要替换的内容public static Matcher getMatcher(@NotNull String text, @NotNull String regex, int flags)
text - 需要匹配的内容regex - 正则flags - 匹配模式public static Matcher getMatcher(@NotNull String text, @NotNull String regex)
regex - 正则text - 需要匹配的内容public static int indexOf(@NotNull
String text,
@NotNull
String regex,
int flags)
regex - 正则text - 需要匹配的内容flags - 匹配模式public static int indexOf(@NotNull
String text,
@NotNull
String regex)
regex - 正则text - 需要匹配的内容public static String match(@NotNull String text, @NotNull String regex, int item, int group, int flags)
regex - 正则text - 需要匹配的内容item - 匹配项group - 捕获组flags - 匹配模式public static String match(@NotNull String text, @NotNull String regex, int item, int group)
text - 需要匹配的内容regex - 正则item - 匹配项group - 捕获组public static String match(@NotNull String text, @NotNull String regex, int item)
text - 需要匹配的内容regex - 正则item - 匹配项public static String matchFirst(@NotNull String text, @NotNull String regex, int group, int flags)
text - 需要匹配的内容regex - 正则group - 捕获组flags - 匹配模式public static String matchFirst(@NotNull String text, @NotNull String regex, int group)
text - 需要匹配的内容regex - 正则group - 捕获组public static String matchFirst(@NotNull String text, @NotNull String regex)
text - 需要匹配的内容regex - 正则public static boolean isMatch(@NotNull
String text,
@NotNull
String regex,
int flags)
text - 需要匹配的内容regex - 正则flags - 匹配模式public static boolean isMatch(@NotNull
String text,
@NotNull
String regex)
text - 需要匹配的内容regex - 正则public static List<String> matches(@NotNull String text, @NotNull String regex, int group, int flags)
text - 需要匹配的内容regex - 正则group - 捕获组flags - 匹配模式public static List<String> matches(@NotNull String text, @NotNull String regex, int group)
text - 需要匹配的内容regex - 正则group - 捕获组public static List<String> matches(@NotNull String text, @NotNull String regex)
text - 需要匹配的内容regex - 正则public static String replace(@NotNull String text, @NotNull String regex, @NotNull String replacement, int item, int group, int flags)
text - 需要替换的内容regex - 正则replacement - 替换值item - 匹配项group - 捕获组flags - 匹配模式public static String replace(@NotNull String text, @NotNull String regex, @NotNull String replacement, int item, int flags)
text - 需要替换的内容regex - 正则replacement - 替换值item - 匹配项flags - 匹配模式public static String replace(@NotNull String text, @NotNull String regex, @NotNull String replacement, int item)
text - 需要替换的内容regex - 正则replacement - 替换值item - 匹配项public static String replaceFirst(@NotNull String text, @NotNull String regex, @NotNull String replacement, int group, int flags)
text - 需要替换的内容regex - 正则replacement - 替换值group - 捕获组public static String replaceFirst(@NotNull String text, @NotNull String regex, @NotNull String replacement, int group)
text - 需要替换的内容regex - 正则replacement - 替换值group - 捕获组public static String replaceFirst(@NotNull String text, @NotNull String regex, @NotNull String replacement)
text - 需要替换的内容regex - 正则replacement - 替换值public static String replaceAll(@NotNull String text, @NotNull String regex, @NotNull String replacement, int group, int flags)
text - 需要替换的内容regex - 正则replacement - 替换值group - 捕获组flags - 匹配模式public static String replaceAll(@NotNull String text, @NotNull String regex, @NotNull String replacement, int group)
text - 需要替换的内容regex - 正则replacement - 替换值group - 捕获组public static boolean containsHanZi(String source)
source - 需要匹配的内容Copyright © 2021. All rights reserved.