Skip to content

Instantly share code, notes, and snippets.

@wvpv
Created December 11, 2015 17:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save wvpv/7fd5076dd983796e77cf to your computer and use it in GitHub Desktop.
Save wvpv/7fd5076dd983796e77cf to your computer and use it in GitHub Desktop.
SFMC AMScript Regex Match
%%[
var @str1, @str1b, @str2, @str2b, @str3, @str3b, @str4, @str4b
set @str1 = "whee 1/2 whoop"
set @str1b = replace(@str1,regexmatch(@str1, "\s\w/\w\s" , 0 , "IgnoreCase"), " ")
set @str2 = "whee *derp* whoop"
set @str2b = replace(@str2,regexmatch(@str2, "\*\w+\*" , 0 , "IgnoreCase"), "")
set @str3 = "whee (whatev) whoop"
set @str3b = replace(@str3,regexmatch(@str3, "\s\(.+\)\s" , 0 , "IgnoreCase"), " ")
set @str4 = "whee/whoop"
set @str4b = replace(@str4,"/"," / ")
]%%
Orig: %%=v(@str1)=%%<br/>
Fixed: %%=v(@str1b)=%%<br/>
Orig: %%=v(@str2)=%%<br/>
Fixed: %%=v(@str2b)=%%<br/>
Orig: %%=v(@str3)=%%<br/>
Fixed: %%=v(@str3b)=%%<br/>
Orig: %%=v(@str4)=%%<br/>
Fixed: %%=v(@str4b)=%%<br/>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment