---
title: First match of a text against a regular expression in Centrldesk
description: First match of a text against a regular expression in Centrldesk
---

[Centrldesk help center ](https://www.centrldesk.com/help)

# [First match of a text against a regular expression in Centrldesk](https://www.centrldesk.com/help/library-text-functions-firstmatch)

 Written by [Sebastian](https://www.centrldesk.com/help/author/sebastian) | Mar 30, 2022 2:39:50 PM

The First Text Match block is used to get the result of the first match of a text against a regular expression.

A regular expression or regex is a sequence of characters that specifies a search pattern in text. If the text matches the regex to be checked, it returns the first result.

Example A:

Using the input Expression 'gr[ae]y' for input Text 'red grey blue gray' the text 'grey' is returned.

Example B:

Using the input Expression 'gr[ae]y' for input Text 'red green blue gray' the text 'gray' is returned.

Result:

Text that first matches the regular expression.

Tips and best practices:

List of regular expression examples:

| **Regex** | **Matches any string that** |
| --- | --- |
| hello | contains {hello} |
| `gray\|grey` | contains {gray, grey} |
| `gr(a\|e)y` | contains {gray, grey} |
| `gr[ae]y` | contains {gray, grey} |
| `b[aeiou]bble` | contains {babble, bebble, bibble, bobble, bubble} |
| `[b-chm-pP]at\|ot` | contains {bat, cat, hat, mat, nat, oat, pat, Pat, ot} |
| `colou?r` | contains {color, colour} |
| `rege(x(es)?\|xps?)` | contains {regex, regexes, regexp, regexps} |
| `go*gle` | contains {ggle, gogle, google, gooogle, goooogle, ...} |
| `go+gle` | contains {gogle, google, gooogle, goooogle, ...} |
| `g(oog)+le` | contains {google, googoogle, googoogoogle, googoogoogoogle, ...} |
| `z{3}` | contains {zzz} |
| `z{3,6}` | contains {zzz, zzzz, zzzzz, zzzzzz} |
| `z{3,}` | contains {zzz, zzzz, zzzzz, zzzzzz} |
| `z{3,}` | contains {zzz, zzzz, zzzzz, ...} |
| `\\d` | contains {0,1,2,3,4,5,6,7,8,9} |
| `\\d{5}(-\\d{4})?` | contains a United States zip code |
| `1\\d{10}` | contains an 11-digit string starting with a 1 |
| `[2-9]\|[12]\\d\|3[0-6]` | contains an integer in the range 2..36 inclusive |
| `^cat` | begins with "cat" |
| `cat$` | ends with "cat" |
| `^cat$` | is exactly "cat" |

Library:

Text

[View full post](https://www.centrldesk.com/help/library-text-functions-firstmatch)

```json
{
  "@context" : "http://schema.org",
  "@type" : "BlogPosting",
  "author" : {
    "@type" : "Person",
    "name" : "Sebastian"
  },
  "dateModified" : "2022-04-28T10:29:32.255Z",
  "datePublished" : "2022-03-30T14:39:50Z",
  "headline" : "First match of a text against a regular expression using First Text Match block",
  "image" : {
    "@type" : "ImageObject",
    "height" : 520,
    "url" : "https://7836215.fs1.hubspotusercontent-na1.net/hubfs/7836215/library-text-functions-firstmatch-1.png",
    "width" : 1900
  },
  "mainEntityOfPage" : "https://www.centrldesk.com/help/library-text-functions-firstmatch",
  "publisher" : {
    "@type" : "Organization",
    "logo" : {
      "@type" : "ImageObject",
      "height" : 60,
      "url" : "/hs/hsstatic/content_shared_assets/static-1.4092/img/default-amp-logo.png",
      "width" : 60
    },
    "name" : "Centrldesk help center"
  }
}
```