mirror of
https://gitee.com/dromara/hutool.git
synced 2025-04-05 17:37:59 +08:00
fix bug
This commit is contained in:
parent
727e561c1a
commit
db5bd528ce
@ -25,6 +25,7 @@
|
||||
* 【core 】 修复java.time.Month解析问题(issue#2090@Github)
|
||||
* 【core 】 修复PathUtil.moveContent移动覆盖导致的问题(issue#I4QV0L@Gitee)
|
||||
* 【core 】 修复Opt.ofTry中并发环境下线程安全问题(pr#504@Gitee)
|
||||
* 【core 】 修复PatternFinder中end边界判断问题(issue#2099@Github)
|
||||
|
||||
-------------------------------------------------------------------------------------------------------------
|
||||
# 5.7.19 (2022-01-07)
|
||||
|
@ -571,16 +571,6 @@ public class NetUtil {
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获得本机物理地址
|
||||
*
|
||||
* @return 本机物理地址
|
||||
* @since 5.7.3
|
||||
*/
|
||||
public static byte[] getLocalHardwareAddress() {
|
||||
return getHardwareAddress(getLocalhost());
|
||||
}
|
||||
|
||||
/**
|
||||
* 获得指定地址信息中的硬件地址
|
||||
*
|
||||
@ -604,6 +594,16 @@ public class NetUtil {
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获得本机物理地址
|
||||
*
|
||||
* @return 本机物理地址
|
||||
* @since 5.7.3
|
||||
*/
|
||||
public static byte[] getLocalHardwareAddress() {
|
||||
return getHardwareAddress(getLocalhost());
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取主机名称,一次获取会缓存名称
|
||||
*
|
||||
|
@ -66,7 +66,7 @@ public class PatternFinder extends TextFinder {
|
||||
}else{
|
||||
limit = Math.min(endIndex, text.length());
|
||||
}
|
||||
return end < limit ? end : INDEX_NOT_FOUND;
|
||||
return end <= limit ? end : INDEX_NOT_FOUND;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -87,9 +87,8 @@ public class SplitIter extends ComputeIter<String> implements Serializable {
|
||||
}
|
||||
|
||||
// 找到新的分隔符位置
|
||||
final int end = finder.end(start);
|
||||
final String result = text.substring(offset, start);
|
||||
offset = end;
|
||||
offset = finder.end(start);
|
||||
|
||||
if (ignoreEmpty && result.isEmpty()) {
|
||||
// 发现空串且需要忽略时,跳过之
|
||||
|
@ -11,7 +11,7 @@ import java.util.List;
|
||||
* @author Looly
|
||||
*
|
||||
*/
|
||||
public class StrSpliterTest {
|
||||
public class StrSplitterTest {
|
||||
|
||||
@Test
|
||||
public void splitByCharTest(){
|
||||
@ -71,4 +71,22 @@ public class StrSpliterTest {
|
||||
Assert.assertNotNull(strings);
|
||||
Assert.assertEquals(0, strings.length);
|
||||
}
|
||||
|
||||
/**
|
||||
* https://github.com/dromara/hutool/issues/2099
|
||||
*/
|
||||
@Test
|
||||
public void splitByRegexTest(){
|
||||
String text = "01 821 34567890182345617821";
|
||||
List<String> strings = StrSplitter.splitByRegex(text, "21", 0, false, true);
|
||||
Assert.assertEquals(2, strings.size());
|
||||
Assert.assertEquals("01 8", strings.get(0));
|
||||
Assert.assertEquals(" 345678901823456178", strings.get(1));
|
||||
|
||||
strings = StrSplitter.splitByRegex(text, "21", 0, false, false);
|
||||
Assert.assertEquals(3, strings.size());
|
||||
Assert.assertEquals("01 8", strings.get(0));
|
||||
Assert.assertEquals(" 345678901823456178", strings.get(1));
|
||||
Assert.assertEquals("", strings.get(2));
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user