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

# Regex

## Definition

```fsharp theme={null}
open System.Text.RegularExpressions

let regex = Regex("^\d{2,4}$")
```

**Mit Options**:

```fsharp theme={null}
let regex = Regex("^\w{2,4}$", RegexOptions.IgnoreCase)
```

## Matching

```fsharp theme={null}
let wordRegex = Regex(@"^hello$", RegexOptions.IgnoreCase)
let isHello text =
    wordRegex.IsMatch(text)
    

let checkEmail email =
    let regex = Regex(@"^[\w.-]+@[\w.-]+\.(com|ch)$")

    match regex.IsMatch(email) with
    | true -> "Valid"
    | false -> "Invalid"
```
