UUID

HTTP 请求

加密/解密

Common 常用模块

Reflection 反射

Input/Output 输入/输出

RegExpUtils 教程

RegExpUtils 类提供了用于匹配字符串、提取匹配组和查找字符串中所有匹配项的方法。这些方法可用于验证输入、解析文本等。

方法

1. isMatch(Pattern pattern, String str)

检查字符串是否匹配给定的正则表达式模式。

示例:

Pattern pattern = Pattern.compile("^a");
boolean matches = RegExpUtils.isMatch(pattern, "abc");
// matches 将会是 true

2. regMatch(String regexp, String str, int groupIndex)

使用正则表达式在字符串中查找匹配项并返回指定的组。

示例:

String match = RegExpUtils.regMatch("^a(b)", "abc", 1);
// match 将会是 "b"

3. regMatch(String regexp, String str)

使用正则表达式在字符串中查找匹配项并返回第一个组。

示例:

String match = RegExpUtils.regMatch("^a", "abc");
// match 将会是 "a"

4. regMatchAll(String regexp, String str)

使用正则表达式在字符串中查找所有匹配项并返回它们的数组。

示例:

String[] matches = RegExpUtils.regMatchAll("\\d+", "abc123def456");
// matches 将会是 ["123", "456"]