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
Raghu_devRaghu_dev 

Find and replace a string on a string field

Hello all !!

I have to do a find and replace a string on a variable (string). I know there is a matcher object but I couldnt find much documentation on the usage. Any one else used this object ? or is there any other simple function to get this done. Pls help

Thanks
Raghu


Message Edited by Raghu_dev on 05-14-2008 05:45 PM
Best Answer chosen by Admin (Salesforce Developers) 
Raghu_devRaghu_dev
Thank you ckemp.

I did the following and everything is working fine.

Code:
acntSaleDet = acntSaleDet.replace('Amount $', '<br>Amount $');




All Answers

ckempckemp
Raghu,

Take a look at the Apex Developer's Guide, specifically the "Pattern and Matcher Classes" on p.185.  You'll have to use the replaceAll() or replaceFirst() methods for the Matcher object, described on p.193.
Raghu_devRaghu_dev
Thank you ckemp.

I did the following and everything is working fine.

Code:
acntSaleDet = acntSaleDet.replace('Amount $', '<br>Amount $');




This was selected as the best answer
JimPDXJimPDX
The section on "Patterns and Matchers" is now on Page 278 (bottom)
David Roberts 4David Roberts 4
It's moved again: https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_dev_guide.htm
Roberto NavarreteRoberto Navarrete

Hello Team,

How could i use Regular Expressions in my replace function, i had to remove the first number 0 in the String, anyone can help me please???

C.Rut__c = C.Rut_Indexado__c = RutArreglado.replace('0','');