+ Start a Discussion

value from the brackets regex expression

Please tell me how to get the value from the bracket in regex expression. i am trying to get the number from the bracket.

String selectvalue = '456TATA(Test)(123)';
Pattern p = Pattern.compile('(\B)');
String test = p.matcher(selectvalue).replaceAll('');
inputvalue = test;
return null;


I want '123' from 456TATA(Test)(123).
please help me to solve this



First thing get your hands polished on Regex and here are some funtastic tools




Coming to Apex, you are using Apex classes implict compiler for Regular Expression so here is another example I have ony my site for you




Happy coding

-ForceLabs (Visit Webpage for more)


I verfied on gskinner online regular expression complier and this is pretty neat capture Just try this (?:ABC)  : which mean this expression groups multiple tokens together without creating a capturing group. This allows you to apply quantifiers to the full group.


So in your case -


 Pattern would be - (?:123)


Tested and Verified on Gskinner - check and verify




Happy coding

-ForceLabs (Visit Webpage for more)