Skip to main content
6 votes
Accepted

Using String.replaceAll() to remove character combination

You could use replaceAll with a regular expression as follows: url = url.replaceAll('-+','-'); This says "match one or more (+) hyphens (-)" and we replace it with the singular hyphen (-).
sfdcfox's user avatar
  • 502k
4 votes
Accepted

Replace function - SQL - Data Extension

Can likely use the TRIM(), LTRIM() or RTRIM() functions. I vaguely remember that the more general TRIM() does not work in SFMC, so in this case you would want to use LTRIM(). For example, say you have ...
Gortonington's user avatar
  • 30.8k
4 votes
Accepted

Regex to find dd/mm/yyyy

There are two issues: replace(String target, String replacement) doesn't take a regExp as input, but a literal string. You should have used replaceAll(String regExp, String replacement) Strings are ...
RubenDG's user avatar
  • 9,567
4 votes
Accepted

Replacing text in lightning email template from apex

You shouldn't replace line breaks (\r\n) with <div>&nbsp;</div>, because that's semantically invalid HTML. Instead, you should split the lines by line break, and wrap them in <p>:...
sfdcfox's user avatar
  • 502k
2 votes

I need to replace white space to either side of a word

You probably want to use RegExMatch in your AMPscript. You want something like: %%[ var @HeroProductTxt var @pattern var @match set @HeroProductTxt = "whee t-shirt whoop" set @pattern = &...
Phil W's user avatar
  • 38.1k
2 votes

Replace character in string in specific position (ie not first, not all)

Apex doesn't really support that. Strings are as in Java, immutable objects, so you can only create modified copies, but not update the original. It has to do with Java's String Pool. So, replaceFirst ...
sfdcfox's user avatar
  • 502k
2 votes
Accepted

Using replace() to remove a value from an array in LWC with a RegExp

Someone was kind enough to show me a pretty easy way to do this in JS: @track myList = ['a', 'b', 'c']; @track removeValue = 'b'; this.myList = this.myList.filter(value => value !== this....
gNerb's user avatar
  • 9,588
2 votes

ReplaceAll does not function Apex

Strings are immutable. This means that all String functions return a new String value rather than modifying the String you called the method on, since a String cannot change. You need to capture those ...
sfdcfox's user avatar
  • 502k
2 votes
Accepted

Removing leading zeroes in Date String

If you really want a locally formatted date, you can use Date.parse and Date.format: String shipDate = '04/06/2022'; System.debug(Date.parse(shipDate).format()); However, be aware that Date.parse ...
sfdcfox's user avatar
  • 502k
2 votes

How to update null records in JSON

Try something like this instead of manipulating the string directly: Map<String, Object> data = (Map<String, Object>) JSON.deserializeUntyped(jsonResponse); List<Object> matches = (...
ApexAdam's user avatar
  • 173
1 vote

How to update null records in JSON

Do not manipulate the string. Deserialize it and remove the null from the list. The first step is define a custom Apex class to map that response, then you can leverage typed deserialization, finally ...
RubenDG's user avatar
  • 9,567
1 vote

Apex replace \" in string

System.assertEquals(jsonString, 'Error fatal', 'Assertion failed'); Should be: System.assertEquals('Error fatal', jsonString2, 'Assertion failed'); Because strings are immutable (cannot be changed), ...
sfdcfox's user avatar
  • 502k
1 vote

Replace double quotes in dataview Bounce

The three fields SMTPBounceReason, SMTPMessage and SMTPCode in the bounce data view are usual suspects to break your sql, because they can contain completely random stuff, including "A joke line ...
Jonas Lamberty's user avatar
1 vote

Remove spaces and accents from a value field to put it in a From Email Adress field - dynamic sender profile

I would use a combination of AMP Script and SSJS to handle this. I would setup the workflow as follows: Step 1) Get the Value %%[ SET @accountname = AttributeValue("Opportunity:Account:Name&...
JordanGS's user avatar
  • 198
1 vote

Remove spaces and accents from a value field to put it in a From Email Adress field - dynamic sender profile

Honestly there is no simple solution here so it is gonna be a mess and far from efficient in AMPscript. Would be better to manipulate prior to send. Below is partial example on approach: %%[ set @...
Gortonington's user avatar
  • 30.8k
1 vote
Accepted

Modify string value in soql list and add back to list

You don't want to remove the commas, you just want to escape them properly. You'd also have problems with quote characters ("). Just do this: getCustomerExport = [SELECT Customer_ID__c, Name from ...
sfdcfox's user avatar
  • 502k

Only top scored, non community-wiki answers of a minimum length are eligible