> ## Documentation Index
> Fetch the complete documentation index at: https://docs.alumio.com/llms.txt
> Use this file to discover all available pages before exploring further.

# String: Matches regular expression

> Checks that a string matches the supplied regular expression.

export const FormField = ({property, label, required = false, diType, uiPatterns, children}) => {
  const patterns = Array.isArray(uiPatterns) ? uiPatterns : uiPatterns ? [uiPatterns] : [];
  return <div style={{
    margin: '1.5rem 0'
  }}>
      <div style={{
    display: 'flex',
    alignItems: 'baseline',
    flexWrap: 'wrap',
    gap: '0.5rem',
    marginBottom: '0.25rem'
  }}>
        <strong>{label}</strong>
        <span style={{
    fontSize: '0.7rem',
    fontWeight: 600,
    textTransform: 'uppercase',
    letterSpacing: '0.04em',
    color: required ? '#6241f5' : '#6b7280'
  }}>
          {required ? 'Required' : 'Optional'}
        </span>
      </div>

      <div>{children}</div>

      {diType || patterns.length > 0 ? <p style={{
    fontSize: '0.85rem',
    color: '#6b7280',
    marginBottom: 0
  }}>
          {diType ? <>
              See the <a href={`/references/${diType}`}>{diType}</a> reference.{' '}
            </> : null}
          {patterns.length > 0 ? <>
              Accepts a <a href={`/documentation/placeholders-and-patterns/patterns#${patterns[0]}`}>pattern</a>.
            </> : null}
        </p> : null}
    </div>;
};

Passes when the incoming text matches a regular expression you supply. A regular expression is a precise pattern language, useful when a simple wildcard is not specific enough, for example to confirm a product code follows an exact format, or to act only on email addresses from a particular domain.

Unlike a wildcard pattern, where `*` and `?` are the only special characters, a regular expression lets you spell out exactly what each part of the text must look like: which characters are allowed, how many of them, and where they may appear. You write the expression including its delimiters, such as `/^[A-Z]{3}-[0-9]{4}$/`, which here means "three capital letters, a dash, then exactly four digits, and nothing else". If you only need to check that text starts with, ends with, or contains something, the simpler [String: Matches wildcard pattern](/references/condition/string-match) is usually easier.

This documentation describes: [Schema](/schemas/condition/string-regex)

## Fields

<FormField property="value" label="Value" required>
  The regular expression the incoming text is checked against, written including its delimiters, such as `/^[A-Z]{3}-[0-9]{4}$/`. The condition passes when the text matches the expression and fails when it does not. You can build and try out an expression at [Regex101](https://regex101.com) before pasting it here.
</FormField>

## Sample data

With the expression set to `/^[A-Z]{3}-[0-9]{4}$/`, the condition checks whether a product code is exactly three capital letters, a dash, and four digits.

| Field | Value                   |
| ----- | ----------------------- |
| Value | `/^[A-Z]{3}-[0-9]{4}$/` |

| Value      | Result         |
| ---------- | -------------- |
| `ABC-1234` | Matches        |
| `AB-12`    | Does not match |

```json Configuration theme={null}
{
  "prototype": "string-regex",
  "parameters": {
    "value": "/^[A-Z]{3}-[0-9]{4}$/"
  }
}
```
