java字符串split
- 摘要:System.out.println(":ab:cd:ef::".split(":").length);//末尾分隔符全部忽略System.out.println(":ab:cd:ef::".split(":",-1).length);//不忽略任何一个分隔符System.out.println(StringUtils.split(":ab:cd:ef::",":").length);//最前面的和末尾的分隔符全部都忽略,apachecommonsSystem.out.println
- 标签:Java 字符串
class="dp-j" style="border: none; color: #5c5c5c; font-family: Consolas, 'Courier New', Courier, mono, serif; font-size: 12px; line-height: 26px; margin-bottom: 1px !important; margin-left: 45px !important;">
- System.out.println(":ab:cd:ef::".split(":").length);??
- ??System.out.println(":ab:cd:ef::".split(":",-1).length);??
- ??System.out.println(StringUtils.split(":ab:cd:ef::",":").length);??
- ??System.out.println(StringUtils.splitPreserveAllTokens(":ab:cd:ef::",":").length);??
- 输出:??
- 4??
- 6??
- 3??
- 6??