+ Start a Discussion
SandrineSandrine 

removing semi colon from the text in apex

Hello,

I am receiving a vales from api.
instead of Value i get "Value", How can i remove the two semicolon if they exsist in apex code.

Thank you for suggetion
Best Answer chosen by Sandrine
Raj VakatiRaj Vakati
String s1='"'+'Value'+'"'.replace('"', '');
String s2 = s1.replace('"', '');
System.debug('s2'+s2);

 

All Answers

Neethu uNeethu u
Hi
Please try the below replace function , it will replace the characters. The example I wrote is for double quotes. This will work with other semicolon, colon etc.

String s1='"'+'Value'+'"';
String s2 = s1.replace('"', '');

Please mark it as best answer if it resolved your issue.

Regards,
Neethu
Parmanand PathakParmanand Pathak
Try below code - 
String s1= 'Hello;Hi;bye';
String s2 = s1.replace(';', '');
system.debug(s2);

Thanks,
Parmanand Pathak
Raj VakatiRaj Vakati
String s1='"'+'Value'+'"'.replace('"', '');
String s2 = s1.replace('"', '');
System.debug('s2'+s2);

 
This was selected as the best answer