update 优化 RegexUtils#extractFromString 方法未匹配返回null不返回默认值问题

This commit is contained in:
疯狂的狮子Li 2024-08-29 14:12:07 +08:00
parent 581b6e03d5
commit cac0a4cd16

View File

@ -21,7 +21,8 @@ public final class RegexUtils extends ReUtil {
*/
public static String extractFromString(String input, String regex, String defaultInput) {
try {
return ReUtil.get(regex, input, 1);
String str = ReUtil.get(regex, input, 1);
return str == null ? defaultInput : str;
} catch (Exception e) {
return defaultInput;
}