无法在String拆分中获取正则表达式示例

Jim*_*Jim 2 java regex string

我无法从String splitSUN教程中获得这些示例:

例如 "boo:and:foo"

Regex   Limit   Result  

o   5   { "b", "", ":and:f", "", "" }  
o   -2  { "b", "", ":and:f", "", "" }  
o   0   { "b", "", ":and:f" }  
Run Code Online (Sandbox Code Playgroud)

我无法理解结果.
我读到,对于负限制,模式应用尽可能多次,对于正限制,它应用n-1次等.

但我无法理解在每种情况下如何形成结果数组.

例如,在第一种情况下,为什么我们"中的位置有1" 1,但2""的位置34
其余的相同.

有帮助吗?

mbh*_*mbh 5

情况1:

很直接

第1步:处理boo:和:foo

"b"  and  "o:and:foo"
Run Code Online (Sandbox Code Playgroud)

第2步:处理o:和:foo

"" and ":and:foo"
Run Code Online (Sandbox Code Playgroud)

第3步:处理:和:foo

":and:f" and "o"
Run Code Online (Sandbox Code Playgroud)

第4步:处理o

""  and ""
Run Code Online (Sandbox Code Playgroud)

情况2:它是负限制,因此它尝试尽可能多地应用模式"o".因此与上述相同.之后,我们留下两个空字符串,不再需要拆分.

情况3:0,与情况2相同,但它丢弃尾随的空字符串.因此它丢弃了最后两个字符串