-1

I am having string as below and want prefix to be removed [*TESTABC*]

String a = "[*TESTABC*]test@test.com";

Expected result: test@test.com

I tried below code but it is removing the bracklets only. I need to remove the inner content also.

The string with come in this pattern only. Please help.

String s = "[*TESTABC*]test@test.com";
 String regex = "\\[|\\]";
 s = s.replaceAll(regex, "");
 System.out.println(s); //*TESTABC*test@test.com
Manan Kapoor
  • 675
  • 1
  • 11
  • 28

1 Answers1

0
int index;
String s = "[*TESTABC*]test@test.com";
index=s.indexOf(']');
s=s.substring(index+1);
System.out.println(s);

**i solve your question according to your problem and output **