public class Patterns extends Object
| 构造器和说明 |
|---|
Patterns() |
| 限定符和类型 | 方法和说明 |
|---|---|
static String |
escape(char c)
转义字符,将正则的关键字转义
|
static String |
escape(CharSequence content)
转义字符串,将正则的关键字转义
|
static boolean |
find(Pattern pattern,
CharSequence content) |
static boolean |
find(String regex,
CharSequence content) |
static List<String> |
getAllGroups(Pattern pattern,
CharSequence content,
boolean withGroup0) |
static List<String> |
getAllGroups(Pattern pattern,
CharSequence content,
boolean withGroup0,
boolean findAll) |
static List<String> |
getAllGroups(String regex,
CharSequence content,
boolean withGroup0) |
static List<String> |
getAllGroups(String regex,
CharSequence content,
boolean withGroup0,
boolean findAll) |
static String |
getGroup(Pattern pattern,
CharSequence content,
int groupIndex) |
static String |
getGroup(Pattern pattern,
CharSequence content,
String groupName) |
static String |
getGroup(String regex,
CharSequence content,
int groupIndex) |
static String |
getGroup(String regex,
CharSequence content,
String groupName) |
static Pattern |
getPattern(String regex) |
static Pattern |
getPattern(String regex,
int flags) |
static Pattern |
getWholePattern(String regex) |
static Pattern |
getWholePattern(String regex,
int flags) |
static MatchResult |
indexOf(Pattern pattern,
CharSequence content)
找到指定模式匹配到字符串的开始位置
|
static MatchResult |
indexOf(String regex,
CharSequence content)
找到指定正则匹配到字符串的开始位置
|
static MatchResult |
lastIndexOf(Pattern pattern,
CharSequence content)
找到指定模式匹配到最后一个字符串的位置
|
static MatchResult |
lastIndexOf(String regex,
CharSequence content)
找到指定正则匹配到第一个字符串的位置
|
static Matcher |
matcher(Pattern pattern,
CharSequence content) |
static Matcher |
matcher(String regex,
CharSequence content) |
static boolean |
matches(Pattern pattern,
CharSequence content) |
static boolean |
matches(String regex,
CharSequence content) |
static boolean |
matchesAll(Pattern pattern,
CharSequence... contents)
判断是否所有字符串都匹配,数组为空时返回true
|
static boolean |
matchesAny(Pattern pattern,
CharSequence... contents)
判断是否存在任意字符串匹配,数组为空时返回false
|
static String |
quote(String regex) |
static Pattern |
quoteWhole(Pattern pattern) |
static String |
quoteWhole(String regex) |
public static boolean find(String regex, CharSequence content)
public static boolean find(Pattern pattern, CharSequence content)
public static boolean matches(String regex, CharSequence content)
public static boolean matches(Pattern pattern, CharSequence content)
public static boolean matchesAny(Pattern pattern, CharSequence... contents)
public static boolean matchesAll(Pattern pattern, CharSequence... contents)
public static Matcher matcher(String regex, CharSequence content)
public static Matcher matcher(Pattern pattern, CharSequence content)
public static String getGroup(String regex, CharSequence content, int groupIndex)
public static String getGroup(String regex, CharSequence content, String groupName)
public static String getGroup(Pattern pattern, CharSequence content, int groupIndex)
public static String getGroup(Pattern pattern, CharSequence content, String groupName)
public static List<String> getAllGroups(String regex, CharSequence content, boolean withGroup0)
public static List<String> getAllGroups(Pattern pattern, CharSequence content, boolean withGroup0)
public static List<String> getAllGroups(String regex, CharSequence content, boolean withGroup0, boolean findAll)
public static List<String> getAllGroups(Pattern pattern, CharSequence content, boolean withGroup0, boolean findAll)
public static MatchResult indexOf(String regex, CharSequence content)
regex - 正则content - 字符串null表示未找到public static MatchResult indexOf(Pattern pattern, CharSequence content)
pattern - 模式content - 字符串null表示未找到public static MatchResult lastIndexOf(String regex, CharSequence content)
regex - 正则content - 字符串null表示未找到public static MatchResult lastIndexOf(Pattern pattern, CharSequence content)
pattern - 模式content - 字符串null表示未找到public static String escape(char c)
c - 字符public static String escape(CharSequence content)
content - 文本Copyright © 2025 fossc. All rights reserved.