且构网

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

如何从文件中删除特定字符?

更新时间:2023-12-04 20:23:22

您可以使用这个(用java风格编写,用于 replaceAll() method):

You can use this (written in java style, to use with replaceAll() method):

search: (?<!\\\\)(\"(?>[^\\\"]++|\\\\{2}|\\\\.)*+\"),(\\s*+})
replace: $1$2

示例:

String pattern = "(?<!\\\\)(\"(?>[^\\\"]++|\\\\{2}|\\\\.)*+\"),(\\s*+})";
String result = yourJson.replaceAll(pattern, "$1$2");