<iframe src="https://www.googletagmanager.com/ns.html?id=GTM-K2HM5C" height="0" width="0" style="display:none;visibility:hidden">
  1. Knowledge base
  2. Expression Engine Playbook

How to remove spaces

In this article, we will outline how to remove spaces using the expression engine feature, including 4 examples of use cases.

Use case:

Let's say you have some spaces in one of your product titles and you wish to remove them and make sure the title remains clean. It can be in front of your product title, at the end of your product title or in both ends.  Also, in certain cases, you will need to remove all spaces from a field.

Example 1: you have additional spaces in front of your product title. Here is how to remove spaces to the left:

The command you write is as follows: RemoveSpacesLeft(field1)


Example 2: if you have spaces at the end of your product title, here is how to remove spaces to the right:

NB: the spaces to the right might be invisible for you at first sight, but we recommend you use the feature as a "safety net",  making sure that you avoid any potential confusion or disapproval. 

The command you write is as follows: RemoveSpacesRight(field1)


Example 3: in certain cases, you will have spaces in both ends of the title, here is how to remove spaces in both ends:

The command you write is as follows: RemoveSpacesInBothEnds(field1)


Example 4: in certain cases, you will have spaces in between characters and you will want to remove all spaces. Here is how it works:

The command you write is as follows: RemoveAllSpaces(field1)


You can always combine the removal of spaces with other commands, making sure that the field you are optimizing remains as clear as possible.