Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我正在尝试删除出现在
[,{
我在这里用lookbehind和lookahead尝试了两件事-
第一个是
"(?=\\[),(?=})"
第二个是放在(?=[),(?=})一边 Pattern.quote()。
(?=[),(?=})
然后我做了一个String.replaceAll(regex,""),但它不起作用。
String.replaceAll(regex,"")
环视哪里出了问题?
无需前瞻/后视,只需使用:str.replaceAll("\\{,\\[", "{[");。
str.replaceAll("\\{,\\[", "{[");
关于什么
String thing = "[,{"; thing.replaceAll("\\[,\\{", "[{");
如果你想使用后视,我认为语法是:
String pattern = "(?<=\\[),(?=\\{)";
(我在您的后视中没有看到“<”。)