- "10 10 [by]"
- "1232 1232 [en]"
expected:
- "10 10"
- "1232 1232"
I want to get string without [] and value inside it.
I tried companyCodeValue1.replaceFirst("\s*([^[]]*)$", "") but I have issue with []…
Does anyone know how to implement regular expression for catching that case?
>Solution :
The regex you’re looking for it’s this one right here: \[.*\]
https://regex101.com/r/nDkL0H/1
Pattern p = Pattern.compile("\\[.*\\]");
Matcher m = p.matcher("10 10 [by]");
String res = m.replaceAll("");