Remove everything in parentheses java using regex

前端 未结 7 1036
忘掉有多难
忘掉有多难 2020-12-16 20:01

I\'ve used the following regex to try to remove parentheses and everything within them in a string called name.

name.replaceAll(\"\\\\(.*\\\\)\"         


        
7条回答
  •  悲哀的现实
    2020-12-16 20:27

    To get around the .* removing everything in between two sets of parentheses you can try :

    name = name.replaceAll("\\(?.*?\\)", "");
    

提交回复
热议问题