# `Unicode.Transform.Pattern`
[🔗](https://github.com/elixir-unicode/unicode_transform/blob/v1.1.0/lib/unicode/transform/pattern.ex#L1)

Compiles CLDR transform rule patterns into Elixir regexes.

Transform patterns can contain:

* Literal characters.

* Unicode set notation: `[:Mn:]`, `[[:Latin:][0-9]]`.

* Quantifiers: `+`, `*`, `?`.

* Capture groups: `(...)` for backreferences.

* Escaped characters: `\:`, `\u0041`.

* Quoted literals: `'text'`.

# `apply_backreferences`

```elixir
@spec apply_backreferences(String.t(), [String.t()]) :: String.t()
```

Applies backreference substitution in a replacement string.

### Arguments

* `replacement` — the replacement string (may contain `$1`, `$2`, etc.).

* `captures` — list of captured groups from the match.

### Returns

The replacement string with backreferences resolved.

# `compile`

```elixir
@spec compile(String.t()) :: {:ok, Regex.t()} | {:error, term()}
```

Compiles a pattern string into a regex.

### Arguments

* `pattern` — the pattern string from a CLDR rule.

### Returns

`{:ok, regex}` or `{:error, reason}`.

# `to_regex_source`

```elixir
@spec to_regex_source(String.t()) :: String.t()
```

Converts a pattern to a regex source string.

### Arguments

* `pattern` — the pattern string.

### Returns

A regex source string.

---

*Consult [api-reference.md](api-reference.md) for complete listing*
