0

Please find below code

String str = 'Hi {!Contact.FirstName} your phone number is {!Contact.Phone}';

I want to replace the string as follow

String str = 'Hi {!contact.firstName} your phone number is {!contact.phone}';

String is not fix so I can't put hard coded value in the replace and replaceAll functions

Please help .

9
  • Can you explain more the global probrem? I am understanding that you are sending and email from apex Commented Feb 24, 2017 at 12:25
  • No need to worry about case, Apex is not case sensitive. So it won't cause any error. Commented Feb 24, 2017 at 12:32
  • I am reading body of email from static resource and have to replace {!ContactFirstName } with actual value Commented Feb 24, 2017 at 12:34
  • @RohitMourya str = str.replace('{!contact.name}' , 'Ranjit') this is not working. Commented Feb 24, 2017 at 12:36
  • 1
    str.replace('{!contact.Firstname}' , 'Ranjit') you need to use firstName not name Commented Feb 24, 2017 at 13:03

1 Answer 1

0

First convert your string to lower cap with the below code

str = str.toLowerCase();

then replace the string

str.replace('{!contact.Firstname}' , 'Ranjit')

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.