Man*_*uel 1 java regex string split
我喜欢使用split(regex)函数将字符串拆分为数组.
我想用分号分割它;- 但是String(\;)中也有"转义"分号,不应该用于分割.
;
\;
是否有正则.split(regex)函数可以执行此操作?
.split(regex)
Roh*_*ain 6
使用negative look-behind拆就semi-colon没有之前\\: -
negative look-behind
semi-colon
\\
str.split("(?<!\\\\);");
您需要使用4 backslashes- 为Java转义一次反斜杠,然后再次为正则表达式转义2个反斜杠.
4 backslashes
归档时间:
13 年 前
查看次数:
239 次
最近记录: