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.
我在括号上拆分一个字符串,如下所示:
string.split("\\(\\)");
现在应将以下内容拆分为 5 个单词:
This (is ((()(my test text)
我必须更改什么,以便如果任何拆分字符跟随另一个字符,则不应该存在拆分。
预期结果将是:
This is my test text
使正则表达式不仅选择两个相邻的括号:
[()]+
string.split("[()]+"); // or "(?:\\(|\\))+"