# `PtcRunner.Lisp.Runtime.Regex`
[🔗](https://github.com/andreasronge/ptc_runner/blob/main/lib/ptc_runner/lisp/runtime/regex.ex#L1)

Minimal, safe Regex support for PTC-Lisp.
Uses Erlang's :re directly with match limits for ReDoS protection.

# `extract`

Extract a capture group from a regex match.

- `(extract "ID:(\d+)" "ID:42")` => "42" (group 1)
- `(extract "ID:(\d+)" "ID:42" 0)` => "ID:42" (full match)
- `(extract regex string 2)` => group 2

Accepts both string patterns and compiled regex objects.

# `extract`

# `extract_int`

Extract a capture group and parse as integer.

2-arity: extracts group 1, returns nil on failure
- `(extract-int "age=(\d+)" "age=25")` => 25

4-arity: extracts specified group with default value
- `(extract-int "age=(\d+)" "no match" 1 0)` => 0 (group 1, default 0)
- `(extract-int "x=(\d+) y=(\d+)" s 2 0)` => group 2 with default 0

Accepts both string patterns and compiled regex objects.

# `extract_int`

# `extract_int`

# `re_find`

Find first match of regex in string.
Returns string if no groups, or vector of [full match, group1, ...] if groups.

# `re_matches`

Returns match if regex matches the entire string.

# `re_pattern`

Compile a string into a regex.
Returns opaque {:re_mp, mp, anchored_mp, source} tuple.
Both normal and anchored versions are pre-compiled for performance and safety.

# `re_seq`

Find all matches of regex in string.
Returns list of matches (empty list if no matches).

## Examples
    (re-seq (re-pattern "\d+") "a1b2c3") => ["1" "2" "3"]
    (re-seq (re-pattern "(\d)(\w)") "1a2b") => [["1a" "1" "a"] ["2b" "2" "b"]]

# `re_split`

Split string by regex pattern.
Returns list of substrings.

## Examples
    (re-split (re-pattern "\s+") "a  b   c") => ["a" "b" "c"]
    (re-split (re-pattern ",") "a,b,c") => ["a" "b" "c"]

---

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