Skip to content

Instantly share code, notes, and snippets.

View nmaratasdev's full-sized avatar

Nolan Maratas nmaratasdev

View GitHub Profile
@nmaratasdev
nmaratasdev / ampscript-string-functions-beginner-lowercase.amp
Last active January 2, 2022 07:35
ampscript-string-functions-beginner-lowercase.amp
<!-- Example Code -->
%%[
/*
* Lowercase logic
* Converts the uppercase string to lowercase.
*/
VAR @name
SET @name = Lowercase("JOHN DOE")
]%%
%%=v(@name)=%%
@nmaratasdev
nmaratasdev / ampscript-string-functions-beginner-trim.amp
Last active January 2, 2022 07:35
ampscript-string-functions-beginner-trim
<!-- Example Code -->
%%[
/*
* Trim Logic
* Removes the white space before and after the text.
*/
VAR @value1, @value2
SET @value1 = " Hello World "
SET @value2 = Trim(@value1)
]%%
@nmaratasdev
nmaratasdev / ampscript-string-functions-beginner-empty.amp
Last active January 2, 2022 07:35
ampscript-string-functions-beginner-empty
<!-- Example Code -->
%%[
/*
* Empty logic
* If subscriber FirstName exists then set the name var to FirstName.
* If subscriber FirstName does not exist, then set the name var to Valued Customer.
*/
VAR @name
SET @name = ""
IF NOT EMPTY(@name) THEN
@nmaratasdev
nmaratasdev / ampscript-string-functions-intermediate-concat.amp
Created December 7, 2021 20:10
ampscript-string-functions-intermediate-concat
<!-- Example Code -->
%%[
/*
* Concat Logic
* This combines three string values into a single string to show
*/
VAR @value1, @value2, @value3
SET @value1 = "This "
SET @value2 = "is "
SET @value3 = "cool"
@nmaratasdev
nmaratasdev / ampscript-string-functions-intermediate-indexof.amp
Last active January 2, 2022 07:32
ampscript-string-functions-intermediate-indexof
<!-- Example Code -->
%%[
/**
* IndexOf Logic
* Checks to see if the word Premium exists in the string value.
*/
VAR @cust_status, @cust_coupon
SET @cust_status = "Premium Retail Customer"
IF IndexOf(@cust_status,"Premium") > 0 THEN
SET @cust_coupon = "Show Premium Coupon"
@nmaratasdev
nmaratasdev / ampscript-string-functions-intermediate-length.amp
Last active January 2, 2022 07:32
ampscript-string-functions-intermediate-length
<!-- Example Code -->
%%[
/**
* Length Logic
* The length function returns a number value
*/
VAR @value1, @value2
SET @value1 = "Hello World!"
SET @value2 = Length(@value1)
]%%
@nmaratasdev
nmaratasdev / ampscript-string-functions-intermediate-replace.amp
Last active January 2, 2022 07:32
ampscript-string-functions-intermediate-replac
<!-- Example Code -->
%%[
/**
* Replace Logic
* Replaces 2007 with 2008 from the original string
*/
VAR @value1, @value2
SET @value1 = "The 2007 model is better"
SET @value2 = Replace(@value1,"2007","2008")
]%%
@nmaratasdev
nmaratasdev / ampscript-string-functions-intermediate-substring.amp
Last active January 2, 2022 07:32
ampscript-string-functions-intermediate-substring
<!-- Example Code -->
%%[
/**
* Substring Logic
* Only show two characters starting with the second character position
*/
VAR @value1, @value2
SET @value1 = "ABCDEF"
SET @value2 = Substring(@value1,2,2)
]%%
@nmaratasdev
nmaratasdev / ampscript-basics-part1-constants-boolean.amp
Last active January 2, 2022 07:26
ampscript-basics-part1-constants-boolean
<!-- Example Code -->
%%[
/**
* Constant (Boolean Values)
* Boolean constant values must use the words true or false. They are not surrounded by quotes. They are also NOT case sensitive.
*/
VAR @toggle1, @toggle2, @toggle3, @toggle4, @toggle5, @toggle6, @toggle7, @toggle8
SET @toggle1 = true
SET @toggle2 = false
SET @toggle3 = True
@nmaratasdev
nmaratasdev / ampscript-basics-part1-constants-null.amp
Last active January 2, 2022 07:26
ampscript-basics-part1-constants-null
<!-- Example Code -->
%%[
/**
* Constant (Null Values)
* etaphysical.
*/
VAR @string1, @string2, @string3, @string4
SET @string1 = "String1 Copy Here"
SET @string2 = ""
SET @string3 = ''