Overview
As we dive into more complex AMPscript logic we may come across situations where we need to manipulate string values to achieve different things. We can do this by using the following functions listed below:
- Lowercase(1)
- Uppercase(1)
- Propercase(1)
- Trim(1)
- Empty(1)
Examples
Lowercase Function
An example of when we might use this function is if a client wants us to render email copy in all lowercase letters. For example, let’s say that the client’s data contains values in in all uppercase letters. We can use the Lowercase function to convert the client’s data from uppercase to lowercase without having to manually update data in the data extension.
Uppercase Function
An example of when we might use this function is if a client wants us to render email copy in all uppercase letters. For example, let’s say that the client’s data contains values in all lowercase letters. We can use the Uppercase function to convert the client’s data from lowercase to uppercase without having to manually update data in the data extension.
Propercase Function
An example of when we might use this function is if a client wants us to render email copy using proper case formatting. For example, let’s say that the client’s data contains values in all uppercase letters. We can use the ProperCase function to convert the client’s data from uppercase to proper case without having to manually update data in the data extension.
Trim Function
There may be instances where the client provides data with undesired spaces. An example might be if the client has a field in the sendable data extension called fname. The client accidently uses “ John ” in that field rather than “John”. In order to clean this up prior to using it in the email we use the Trim function to strip out unwanted spaces before and after the data value.
Empty Function
This function is used often to evaluate whether a variable is empty or not. You’ll notice that this function is combined with other functions to evaluate and personalize content. In this example, we check to see if @name is empty or not. If so, then set the @name variable to “Valued Customer” to use as a fallback.
Hi Everyone! I hope this information helps. You can download the full code using the links below. Feel free to modify it to fit your needs. I’d love to get your feedback, did this information help in some way?
AMPscript Empty Function
https://gist.github.com/nmaratasdev/a5afb00eb28ca35934a265abd9e9716c
AMPscript Trim Function
https://gist.github.com/nmaratasdev/d9f8adbf4d757b64774aef4f6e7ffa56
AMPscript ProperCase Function
https://gist.github.com/nmaratasdev/a755839cdda0b334b220f92537fbbeff
AMPscript UpperCase Function
https://gist.github.com/nmaratasdev/8017ac7b39d1130a110825c925a870f0
AMPscript LowerCase Function
https://gist.github.com/nmaratasdev/3cce3012db417d050bc8ab1c34bb73eb