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

# Regex

# \$regex

The `$regex` operator checks if the first string matches the regular expression pattern provided in the second string.

## Input

* An array containing exactly two string values: the input string and the regex pattern

## Output

* `true` if the first string matches the regex pattern
* `false` otherwise

## Examples

### Matching Pattern

```json theme={null}
{
  "$regex": [
    "hello@example.com",
    "^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\\.[a-zA-Z]{2,}$"
  ]
}
```

Result: `true`

### Non-matching Pattern

```json theme={null}
{
  "$regex": [
    "not-an-email",
    "^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\\.[a-zA-Z]{2,}$"
  ]
}
```

Result: `false`

### Field Value

```json theme={null}
{
  "$regex": [
    {
      "$input": "phone_number"
    },
    "^\\+?[1-9]\\d{1,14}$"
  ]
}
```

Result: `true` if the phone\_number field matches the international phone number pattern, otherwise `false`
