# Variables

**URL:** <https://forum.mergado.com/t/variables/506>\
**Category:** Variables\
**Created:** [July 8, 2022, 8:27am UTC](https://forum.mergado.com/t/variables/506 "2022-07-08T08:27:38Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![lehuy](https://forum.mergado.com/user_avatar/forum.mergado.com/lehuy/32/280_2.png) [@lehuy](https://forum.mergado.com/u/lehuy)\
**Post date:** [July 8, 2022, 8:27am UTC](https://forum.mergado.com/t/variables/506/1 "2022-07-08T08:27:38Z")

</div>

In this post, we will learn:

- [What are variables?](https://forum.mergado.com/t/variables/506#what-are-variables-2)
- [Procedure of variable creation](https://forum.mergado.com/t/variables/506#variable-creation-procedure-3)
- [Examples](https://forum.mergado.com/t/variables/506#examples-4)

## Introduction

In the Mergado Editor, you may have encountered a situation where you need to create a placeholder component for all values of a specific element of different products in a [rule](https://forum.mergado.cz/t/pravidla/). That’s what variables are for.

 ![image](https://forum.mergado.com/uploads/default/original/1X/2fbb91833c520ccd79847a1c8467785e161ff500.png)

## What are variables?

_Variables_ in the Mergado Editor represent **placeholders for specific values from elements**. For example, if we have a PRICE\_VAT element in the feed, which contains the final price of the product with VAT, this price can be different for each product. The PRICE\_VAT element therefore contains (across products) a variable numerical value, which we can generally call a variable. So **the variable can have a different value** for each product in the feed.

**Example:** We want to build a product name from multiple elements with different values and we want the name to contain:

- manufacturer,
- original product name used on the e-shop
- and a parameter expressing the size of the product.

We create a [rewriting rule](https://forum.mergado.com/t/rewrite/491), where we fill in `PRODUCTNAME` in the field for the element and write the following 3 variables in the field New content:

- `%MANUFACTURER%`
- `%PRODUCTNAME%`
- `%PARAM_SIZE%`

 ![image](https://forum.mergado.com/uploads/default/original/1X/87c13a069039612d049f9e0c84d12800d97520fd.png)

After applying such a rule, the specific name of the product will be compiled for us in the form, for example: _Adidas Men’s sports shirt XXL._

> ℹ &nbsp;**[MERGADO 2](https://forum.mergado.com/t/what-is-mergado-2/761) already uses the element itself to represent the value** and therefore no longer automatically creates all variables from your feed elements like Mergado 1. However, it still **allows you to create new variables** if needed. The complete management and overview of variables can be found in the left menu under the link _Variables_.

## Variable creation procedure

We add a new variable to the Mergado Editor by **clicking the _New variable_** button on the _Variables_ page and then:

1. **We choose the element** from which the variable will be based.
2. Enter **[regular expression](https://forum.mergado.com/t/basic-overview-of-regular-expression-tags/756)**, which represents a mask for selecting text from the given element.
3. In the _Test text_ field we will see a randomly selected value from the element we selected. By clicking on the _double arrow icon_ we can change the test text or **enter your own text in the field if necessary**.
4. We click on the _Test expression_ button.
5. If we are not satisfied with the result of our regular expression mask, we can **modify** the regular expression and test its application on the sample data again.
6. Once we are satisfied with the regular expression, we **save the specific part** (or parts) of the text corresponding to our regular expression in variables, just enter their name and click on the _Save variable_ button.

 ![image](https://forum.mergado.com/uploads/default/original/1X/b33c1c2600ccd40d6323313dafbfb55ae74cbfa7.png)

> 💡 We also recommend [regex101.com](https://regex101.com/) for testing regular expressions.

## Examples

Users with variables most often **set a new value in some element** (using rules). Variables are also used to **separate a part of (variable) text from some element**.

- **Example 1:** [Get dimensions of products into parameters](https://www.mergado.com/blog/favi-dimensions-description-to-parameter) (article)
- **Example 2:** [Adding color and warranty to the name](https://forum.mergado.com/t/whispering-elements-with-the-symbol-and-values-with-the-symbol/613) (video)
