+ Start a Discussion
Code+1Code+1 

Remove all the characters before _ in String

Hi All,
 I have a string whose value will be like
String a = abc_12345; or
String a= a_1234; or
String a= abcd_23;

In String b = I need to capture the values only after the underscore.
Like b=12345
or b=1234
or b=23
Please let me know how it can be achieved.
 
Rupali PophaliyaRupali Pophaliya
Find below sample code:
String s1 = 'a_1234';
String s2 =  s1.substringAfter('_');
System.assertEquals('1234', s2);