I want to leave a single character inside a bracket, for example, in the string "I part (A) and No (AAA) ", the desired result is" I am running and no (AAA) ", where the other brackets are kept because it is too long, how can I do this in Java? I have tried the following but it does not match anything!
string text = "5 USC meaning 552 (a) (6) (b) and section 1.16 (b)."; Text.replaceAll ("\\ (.? \\)", ""); // "5 USC 552 and Section 1.16" should be returned. "But no! I think the problem is how I am saved from backslash and bracket character, but I have tried several changes like" \\ (.? \ \) "There is no benefit, besides, they start working online on regular expression sites, so I'm completely lost. Text ">
Your regex looks OK - have you forgotten to allot the result in one variable?
text = text.replaceAll ("\\ (.? \\) \"), "");
No comments:
Post a Comment