I'm currently learning Ampscript and SSJS for an email project. I'm trying to remove special characters to a specific object that is being called.
I've came across some things that I think that could help but isnt sure how to use them.
Creating a template for an exact target email. Thought I could use the string.replace as show below. What would be some other options if any?
string = string.replace(/[^a-zA-Z0-9]/g, '');
Current code section below : the @img automatically pull content with special characters that needs to be removed before being used in the email
If RowCount(@customTemplate) != 0 Then
Set @costumTemplate = True
Set @img = Lowercase(Replace(@first_artist, ' ','_'))
ElseIf RowCount(@locationTemplate) != 0 Then
Set @locationTemplate = True
Set @img = Lowercase(Replace(@venue_name,' ','_'))
EndIf
Best Answer
I'd advise against using SSJS in your emails, especially since there is a native AMPScript function for doing the same thing.
Here are a few regex examples from my blog:
Reference:
RegExMatch() Function