Class OpenRegex
java.lang.Object
cloud.opencode.base.string.regex.OpenRegex
Regex Facade - Unified entry point for regex matching and validation operations.
正则门面 - 正则匹配和验证操作的统一入口。
Features | 主要功能:
- Pattern matching and extraction - 模式匹配和提取
- ReDoS protection via pattern length limit - 通过模式长度限制防止ReDoS
- Convenient static match/find/replace methods - 便捷的静态匹配/查找/替换方法
Usage Examples | 使用示例:
boolean matches = OpenRegex.matches("\\d+", "12345");
List<String> found = OpenRegex.findAll("\\d+", "a1b2c3");
String replaced = OpenRegex.replaceAll("\\d", "abc123", "*");
Security | 安全性:
- Thread-safe: Yes (stateless utility) - 线程安全: 是(无状态工具类)
- Null-safe: No (input must not be null) - 空值安全: 否(输入不能为空)
- Since:
- JDK 25, opencode-base-string V1.0.0
- Author:
- Leon Soo www.LeonSoo.com
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptionstatic Patternstatic PatterncompileIgnoreCase(String regex) static booleanstatic intcountMatches(String str, String regex) static StringfindAllGroups(String str, String regex) static Stringstatic StringfindNamedGroups(String str, String regex) static List<int[]> findPositions(String str, String regex) static booleanChecks if string is a valid email address.static booleanChecks if string is a valid ID card number (China).static booleanChecks if string is a valid IPv4 address.static booleanChecks if string is a valid mobile phone number (China).static booleanChecks if string is a valid URL.static booleanChecks if string is a valid UUID format.static booleanstatic booleanstatic StringreplaceAll(String str, String regex, String replacement) static Stringstatic StringreplaceFirst(String str, String regex, String replacement) static String[]static String[]
-
Method Details
-
matches
-
matches
-
contains
-
findFirst
-
findAll
-
findGroup
-
findAllGroups
-
findNamedGroups
-
replaceFirst
-
replaceAll
-
replaceAll
-
split
-
split
-
escape
-
compile
-
compileIgnoreCase
-
countMatches
-
findPositions
-
isEmail
Checks if string is a valid email address. 检查字符串是否为有效的电子邮件地址。- Parameters:
str- the string to check | 要检查的字符串- Returns:
- true if valid email | 如果是有效邮箱返回true
-
isUrl
Checks if string is a valid URL. 检查字符串是否为有效的URL。- Parameters:
str- the string to check | 要检查的字符串- Returns:
- true if valid URL | 如果是有效URL返回true
-
isMobile
Checks if string is a valid mobile phone number (China). 检查字符串是否为有效的手机号码(中国)。- Parameters:
str- the string to check | 要检查的字符串- Returns:
- true if valid mobile number | 如果是有效手机号返回true
-
isIdCard
Checks if string is a valid ID card number (China). 检查字符串是否为有效的身份证号码(中国)。- Parameters:
str- the string to check | 要检查的字符串- Returns:
- true if valid ID card | 如果是有效身份证号返回true
-
isIpv4
Checks if string is a valid IPv4 address. 检查字符串是否为有效的IPv4地址。- Parameters:
str- the string to check | 要检查的字符串- Returns:
- true if valid IPv4 | 如果是有效IPv4返回true
-
isUuid
Checks if string is a valid UUID format. 检查字符串是否为有效的UUID格式。- Parameters:
str- the string to check | 要检查的字符串- Returns:
- true if valid UUID | 如果是有效UUID返回true
-