---
title: "Guide to REGEX() Formula Functions"
description: "Master the art of pattern matching with this comprehensive guide to REGEX() functions."
url: https://help.stackby.com/en/articles/57-guide-to-regex-formula-functions
collection: "Using Formulas"
updated: 2025-01-10
language: en
---

# Guide to REGEX() Formula Functions

Master the art of pattern matching with this comprehensive guide to REGEX() functions.

Regular expressions allow you to find patterns in character combinations in a string. It's super powerful and are used in modern search engines and word processors. 

There are three types of REGEX Function in Stackby. They are REGEX\_MATCH(), REGEX\_EXTRACT(), and REGEX\_REPLACE().

All this are formulas which has advantages and disadvantages depending on the formula output!

In this article, we will learn the following Regular expression functions: 

-   REGEX\_MATCH()
    
-   REGEX\_EXTRACT()
    
-   REGEX\_REPLACE() 
    

## **1\. REGEX\_MATCH**

The REGEX\_MATCH() function returns whether the input text matches a regular expression and outputs in the Boolean data type as a 1 as true or 0 as false result. 

**Example:** Phone number validation and Email validation.

```javascript
Phone No.: REGEX_MATCH( {Phone}, ‘^([+]?[0-9]( |-)?)?(\\(?[0-9]{3}\\)?|[0-9]{3})( |-)?([0-9]{3}( |-)?[0-9]{4}|[a-zA-Z0-9]{7})$‘)
```

```javascript
Email: REGEX_MATCH({Email}, “(\\W|^)[\\w.\\-]{0,25}@[A-Za-z0-9.-]+\\.[A-Za-z]{2,}(\\W|$)“)
```

![](https://d258lu9myqkejp.cloudfront.net/attachment_images/408384a4e82a318544ebcee8ef177d91527d171ede0ece7a83760f0102c40149Screenshot%202022-07-05%20at%204.20.54%20PM.png)

## **2\. REGEX\_EXTRACT()**

In the REGEX\_EXTRACT() function it returns the first substring that matches a regular expression. If the REGEX\_EXTRACT() function finds no matching instance of the provided regular expression it will return an ERROR. 

```javascript
Example: Extracting ID from a URL 
Formula: REGEX_EXTRACT({URL}, “[^=]+$“)
```

![](https://d258lu9myqkejp.cloudfront.net/attachment_images/244bcc3f0a8da7a7e050afb7f854e2913a89e1fb7c826cc862c29fcc6e543442Screenshot%202022-07-05%20at%204.20.35%20PM.png)

**Another example:** Domain Extraction from a URL  
**Formula:**  
REGEX\_EXTRACT( {URL}, ‘^(?:https?:\\\\/\\\\/)?(?:\[^@\\n\]+@)?(?:www\\\\.)?(\[^:\\\\/\\n?\]+)’)

![](https://d258lu9myqkejp.cloudfront.net/attachment_images/eb42a44b37b0a7232e5862c2f2dc7f932c2e4e019e88a2fe16c7ea6b2ba5eb1fScreenshot%202022-07-05%20at%204.20.17%20PM.png)

## **3\. REGEX\_REPLACE()**

The REGEX\_REPLACE() function substitutes all matching substrings with a replacement string value.   
Let’s see if we have to normalize all our phone numbers in the table, we will follow the steps below: 

We’ll first check if we have a valid phone number with REGEX\_MATCH, then we can use REGEX\_REPLACE to bring an output for a normalized phone number.   
  
First use REGEX\_MATCH:

```javascript
REGEX_MATCH( {Phone}, ‘^([+]?[0-9]( |-)?)?(\\(?[0-9]{3}\\)?|[0-9]{3})( |-)?([0-9]{3}( |-)?[0-9]{4}|[a-zA-Z0-9]{7})$‘)
```

Then use REGEX\_REPLACE to normalize:

```javascript
IF({REGEX MATCH}, UPPER(REGEX_REPLACE( {Phone}, ‘[^A-Za-z0-9]‘, ‘’)), ERROR(‘Invalid phone number’))

```

![](https://d258lu9myqkejp.cloudfront.net/attachment_images/fcb89e60ba5aedcda6886ca9789153fb3befaa70cca84502d83177311a1f399cScreenshot%202022-07-05%20at%204.21.04%20PM%20%281%29.png)
