且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

使用Java解析包含转义字符的字符串

更新时间:2023-02-26 11:03:17

你可以用这样的方式改进你用于拆分的正则表达式:

You could perhaps refine your regular expression used with split like this:

split("[^\\];")

要拆分任何东西一个 ;但是如果之前有一个\。破折号也是如此:

To split at anything that is a ";" but not if before that there is a "\". And the same for the dashes:

split("[^\\]-")