# RegExReplace

{% hint style="info" %}
The **`RegExReplace()`** function replaces all matches for <mark style="color:blue;">Pattern</mark> in <mark style="color:blue;">SourceText</mark>, and replaces them with the <mark style="color:blue;">ReplaceText</mark> value.&#x20;

All regex functions use a pattern to check for matches in the input text.&#x20;

For a more complete explanation and special / allowed characters you can visit [**this WEM Forum post**](https://my.wem.io/forum?threadid=459). Here you find a cheat-sheet and a few helpful examples.&#x20;

This function is NOT SQL compatible. For more information about SQL compatibility, see our [documentation](https://docs.wem.io/platform/~/changes/y5gAfiyi2fILzrLzUUHj/wemreference/sql-compatibility).
{% endhint %}

{% hint style="success" %}
Returns <mark style="color:green;">SourceText</mark> with the matching <mark style="color:blue;">patterns</mark> replaced by the <mark style="color:blue;">replace-text</mark> value.

Returns <mark style="color:red;">SourceText</mark> if no matches are found or the pattern is faulty.
{% endhint %}

### Syntax

<details>

<summary><code>RegExReplace(</code><mark style="color:blue;"><code>pattern</code></mark><code>, </code><mark style="color:blue;"><code>sourcetext</code></mark><code>, </code><mark style="color:blue;"><code>replacetext</code></mark><code>)</code></summary>

`RegExReplace("\\d{3}", "Triple (3) numbers like 123 are replaced by zeroes. Some but not all of these 5-niners (99999) become zeroes, and a phonenumber like 020-2402120?", "000")`\
\=> "*Triple (3) numbers like 000 are replaced by zeroes. Some but not all of these 5-niners (00099) become zeroes, and a phonenumber like 000-0000000?"*

</details>

### Parameters

<table><thead><tr><th width="174.82556001240064">Name</th><th width="150">Type</th><th width="150" align="center">Required</th><th width="248.15953250810662">Description</th><th data-hidden>Required?</th></tr></thead><tbody><tr><td><mark style="color:blue;"><code>pattern</code></mark></td><td>text</td><td align="center"><span data-gb-custom-inline data-tag="emoji" data-code="2611">☑️</span></td><td>The pattern you want to replace.</td><td>yes</td></tr><tr><td><mark style="color:blue;"><code>sourcetext</code></mark></td><td>text</td><td align="center"><span data-gb-custom-inline data-tag="emoji" data-code="2611">☑️</span></td><td>The text you want to check for patterns to replace. </td><td>yes</td></tr><tr><td><mark style="color:blue;"><code>replacetext</code></mark></td><td>text</td><td align="center"><span data-gb-custom-inline data-tag="emoji" data-code="2611">☑️</span></td><td>The text you want to replace the pattern with. </td><td>yes</td></tr></tbody></table>
