删除字符串中2个字符之间的所有字符

Mat*_*ata 2 java string char between removeall

我有一个50000行的数据库.我想逐个获取所有行,将它们放入String变量并删除"("和")"之间的所有字符,然后更新该行.我只是不知道如何删除"("和")"之间的所有字符.我想用java做这个.

Voi*_*paw 7

你的正则表达式将是这样的:

data.replaceAll("\\(.*?\\)", "()"); //if you want to keep the brackets
Run Code Online (Sandbox Code Playgroud)

要么

data.replaceAll("\\(.*?\\)", ""); //if you don't want to keep the brackets
Run Code Online (Sandbox Code Playgroud)

该字符串由3部分组成:

\\(  //This part matches the opening bracket
.*?  //This part matches anything in between
\\)  //This part matches the closing bracket
Run Code Online (Sandbox Code Playgroud)

我希望这有帮助