I need to replace Where with Where (

Replace each where+space with where+space+open bracket.

Please suggest me how to do this in Apex code. Is this possible without Matcher Class?


You can use the replace method:

query = query.replace(' WHERE ', ' WHERE (');

Use String class method replaceAll() to do this.

related question link: How to use replaceall to remove all blank space with hypens in apex

string test = 'this is a space where';
string newtest = test.replaceAll('where ','where (');

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.