mirror of
https://gitee.com/chinabugotech/hutool.git
synced 2025-04-19 03:01:48 +08:00
add null check
This commit is contained in:
parent
47847fc7a3
commit
18763decae
@ -269,6 +269,12 @@ public class SplitUtil {
|
||||
* @since 3.0.8
|
||||
*/
|
||||
public static List<String> splitByRegex(final CharSequence str, final String separatorRegex, final int limit, final boolean isTrim, final boolean ignoreEmpty) {
|
||||
if (StrUtil.isEmpty(str)) {
|
||||
return ListUtil.zero();
|
||||
}
|
||||
if(StrUtil.isEmpty(separatorRegex)){
|
||||
return ListUtil.of(str.toString());
|
||||
}
|
||||
final Pattern pattern = PatternPool.get(separatorRegex);
|
||||
return splitByRegex(str, pattern, limit, isTrim, ignoreEmpty);
|
||||
}
|
||||
@ -289,6 +295,9 @@ public class SplitUtil {
|
||||
if (StrUtil.isEmpty(str)) {
|
||||
return ListUtil.zero();
|
||||
}
|
||||
if(null == separatorPattern){
|
||||
return ListUtil.of(str.toString());
|
||||
}
|
||||
final SplitIter splitIter = new SplitIter(str, new PatternFinder(separatorPattern), limit, ignoreEmpty);
|
||||
return splitIter.toList(isTrim);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user