> For the complete documentation index, see [llms.txt](https://help.impact.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://help.impact.com/brand/es/what-would-you-like-to-learn-about/platform-features/promo-codes/regular-expression/regex-explained.md).

# Explicación de Regex

Regex (o expresión regular) es un código que puedes usar para hacer coincidir texto en un caso general y es útil al hacer coincidir códigos promocionales. Regex distingue entre mayúsculas y minúsculas, así que asegúrate de configurar tu regex con el uso de mayúsculas y minúsculas que coincida con tus códigos promocionales.

* Hay tres casos lógicos principales para regex y códigos promocionales: `empieza con`, `termina con`, y `contiene`.
* Para este ejemplo, la base de nuestro código promocional es `SUMMER`.

{% tabs %}
{% tab title="Empieza con" %}
Has emitido un rango de códigos promocionales de verano para socios, `SUMMER20OFF`, `SUMMER10`, y `SUMMER25`. Queremos hacer coincidirlos todos para acreditar a nuestros socios, ¿cómo lo hacemos? Usaríamos la `empieza con` lógica. Simplemente añade un punto y un asterisco al final de tu código promocional base.

La regex debería ser exactamente `^(SUMMER).*`

Esto hará coincidir automáticamente cualquier código promocional que empiece con `SUMMER` y termine con cualquier otro carácter. Cualquier código que no empiece con `SUMMER` no coincidirá.
{% endtab %}

{% tab title="Termina con" %}
Has emitido un rango de códigos promocionales de verano para socios, `20OFFSUMMER`, `10SUMMER`, y `25SUMMER` en el que el código promocional siempre termina en `SUMMER`. ¿Cómo los hacemos coincidir? Usaríamos la `termina con` lógica. Simplemente añade un punto y un asterisco al principio de tu código promocional base y añade un $ para especificar el ancla de tu cadena.

La regex debería ser exactamente `^.*(SUMMER)$`

Esto hará coincidir automáticamente cualquier código promocional que empiece con otros caracteres y termine con `SUMMER`. Cualquier código que no termine con `SUMMER` no coincidirá.
{% endtab %}

{% tab title="Contiene" %}
Has emitido un rango de códigos promocionales de verano para socios, `20SUMMER`, `SUMMER20OFF`, y `EXTRASUMMER10`, donde `SUMMER` aparece en algún lugar del código. Usaríamos la `contiene` lógica. Añade `.*` antes y después de tu código promocional base, y encierra la expresión entre los anclajes ^ y $.

La regex debería ser exactamente `^.*(SUMMER).*$`

Esta regex coincide con un código promocional que contiene `SUMMER` en cualquier parte del código. Cualquier código que no contenga `SUMMER` no coincidirá.
{% endtab %}
{% endtabs %}

Para expresiones más complicadas, ponte en contacto con tu CSM o [contacta con soporte](https://app.impact.com/support/portal.ihtml?createTicket=true\&accountType=ADVERTISER) para obtener ayuda.

{% hint style="success" %}
**Nota:** Puedes eliminar la sensibilidad a mayúsculas y minúsculas de regex añadiendo `(?i)` después de `^` en tu regex.
{% endhint %}

## Ejemplo

```programlisting
^(?i)(SUMMER).*
```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://help.impact.com/brand/es/what-would-you-like-to-learn-about/platform-features/promo-codes/regular-expression/regex-explained.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
