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

2.X
疯狂的狮子Li 2024-08-29 14:12:58 +08:00
parent 3542bb92aa
commit d5ef554e5e
1 changed files with 2 additions and 1 deletions

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;
}