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

# Regular Expression

> Define a reusable regular-expression pattern and flags.

The **Regular Expression** action builds a regex value for other text actions.
Use it with **Matches Regex**, **Extract Text with Regex**, **Replace Text**,
**Split Text**, or **Count Occurrences**.

## Inputs

| Input       | Type   | Required | Description                                                          |
| ----------- | ------ | -------- | -------------------------------------------------------------------- |
| **Pattern** | String | Yes      | A non-empty JavaScript regular-expression pattern. Defaults to `.*`. |
| **Flags**   | String | No       | The selected regex flags. The node defaults to `ig`.                 |

### Flags

| Flag | Setting         | Effect                                                   |
| ---- | --------------- | -------------------------------------------------------- |
| `g`  | **Global**      | Finds or replaces every match instead of only the first. |
| `i`  | **Ignore case** | Matches letters without case sensitivity.                |
| `m`  | **Multiline**   | Makes `^` and `$` work at line boundaries.               |
| `s`  | **Dot-all**     | Allows `.` to match line-break characters.               |

## Outputs

| Output    | Type               | Description                              |
| --------- | ------------------ | ---------------------------------------- |
| **Regex** | Regular expression | The compiled pattern and selected flags. |

## Example: invoice IDs

Set **Pattern** to:

```text theme={null}
\bINV-\d{4}\b
```

Keep **Global** on to find every ID and **Ignore case** on if `inv-1042` should
also match. Connect **Regex** to **Extract Text with Regex** to return the
matches.

<Warning>
  Enter the pattern without wrapping `/` characters. For example, use `\d+`, not
  `/\d+/g`; choose flags separately. An invalid pattern fails when the action
  runs.
</Warning>
