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
RonakPatel.ceRonakPatel.ce 

Regex invalid for string.replaceall('(','');


Hi,

 

i  have to remove '(' and ')' Character from the String
for that i used  string.replaceall('(','');

but i got error Regex invalid :Unclosed Group near index 1(^

 

Can anybody tell me how to solve this problem?

or Any other way to remove ( and ) from the string..

Navatar_DbSupNavatar_DbSup

Hi,

 

You have to use  string.replace method instead of string.replaceall. Try the below code as reference:
string st='sas(hish(ra(i';
string st1=st.replace('(','');
system.debug('@@@@@@@@@@@@@@@@@' +st1);

 

Did this answer your question? If not, let me know what didn't work, or if so, please mark it solved. 

craigmhcraigmh

Yeah, if you just need to remove two characters from a string, there's no need to use replaceAll().

 

yourString = yourString.replace('(', '').replace(')', '');