function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
AbAb 

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 Ab
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