Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Special characters remove?

Tags:

salesforce

How to remove special characters from a string in apex.

Code: selectedStatus = ApexPages.currentPage().getParameters().get('ideaStatus');

value: ideastatus = "We like's it"

I want to remove the ' from the value of ideastatus.

I am trying selectedStatus.replace("'","");

But its not working.

Can anybody suggest how?

like image 227
Kp Gupta Avatar asked Jun 13 '26 20:06

Kp Gupta


1 Answers

Try

selectedStatus.replace('\'', '')

However please note that "We like's it" is grammatically incorrect - it should be "We like it". So you shouldn't have to worry about the apostrophe in this case.

like image 111
naomi Avatar answered Jun 15 '26 10:06

naomi