You need to sign in to do that
Don't have an account?
DJP1S
Splitting '(' and ')' in a string get middle middle characters
Hi, I have a picklist with values like "Boo Foo (2)[0]"
I want to grab the 2 and use it later in a DML statement. However, when I write my code like this:
String s = t.Prospect_Phase_Change__c; system.debug('%%% s: ' + s); s.split('(', 1); system.debug('$$$ s: ' + s);
I get the error "Invalid regex: Unclosed group near index 1 ( ^"
I was planning to split it to the right of the '(' and the left of the ')' and then write that value elsewhere.
String s = 'Boo Foo (2)[0]';
system.debug(' -------- ' + s.substring( s.indexOf( '(' ) + 1, s.indexOf( ')' ) ) );
All Answers
String s = 'Boo Foo (2)[0]';
system.debug(' -------- ' + s.substring( s.indexOf( '(' ) + 1, s.indexOf( ')' ) ) );
Hi
Try this may be it will solve your use.
Thanks, here's what I did: