json
JSON Parse & Manipulate
Parse, build, and edit JSON. Backed by serde_json in Rust, nested get/set, merge, and pretty-print included.
- parse & stringify
- Dot-path access
- Deep merge
- Pretty-print
Regular Expressions
Core Standard Library
re wraps the Rust regex engine. Use it to pull structured data out of logs, validate input, or split strings on a pattern. Syntax matches Rust regex (not PCRE, no lookbehind).
For code that runs the same pattern thousands of times, compile it once and reuse the handle. Capture groups come back numbered or by name; flags cover case-insensitive and multiline matching with proper Unicode behavior.
Import
import "re" |
Quick start
import "re" |
|
let pattern = re.compile(r"(d{4})-(d{2})-(d{2})") |
let m = pattern.match("Event on 2026-07-08") |
print(m.group(1)) |
High-level overview of what re is for.
Parentheses in the pattern become numbered groups (and named groups if you use (?P<name>...)).
Find all matches, or replace with a fixed string. Global replace walks the whole input.
compile parses the pattern once; subsequent match calls skip that cost.
Case-insensitive and multiline flags respect Unicode rules, not just ASCII byte ranges.
26 functions and methods in re. Grouped by category from the standard library docs.
| Signature | Description |
|---|---|
| full | Matched substring |
| start | Start index (byte offset, inclusive) |
| end | End index (byte offset, exclusive) |
| groups | Capture groups - index `0` is the full match, `1+` are parenthesized groups |
| Signature | Description |
|---|---|
| re.valid(pattern, flags?) | `true` if pattern compiles |
| re.escape(text) | Escape literal metacharacters |
| Signature | Description |
|---|---|
| re.test(pattern, text, flags?) | `true` if pattern matches anywhere in `text` |
| re.match(pattern, text, flags?) | `true` if the entire string matches |
| re.search(pattern, text, flags?) | First match → match object, or `nil` |
| re.find_all(pattern, text, flags?) | All matches → array of match objects |
| re.find_all_strings(pattern, text, flags?) | All matches → array of matched strings |
| re.count(pattern, text, flags?) | Number of non-overlapping matches |
| Signature | Description |
|---|---|
| re.replace(pattern, text, replacement, flags?) | Replace all matches |
| re.replace_n(pattern, text, replacement, count, flags?) | Replace first `count` matches |
| re.split(pattern, text, flags?) | Split on pattern → string array |
| Signature | Description |
|---|---|
| re.compile(pattern, flags?) | Compile pattern → positive int handle |
| re.close(handle) | Release handle; returns `true` if it existed |
| re.test_h(handle, text) | Same as `re.test` |
| re.match_h(handle, text) | Same as `re.match` |
| re.search_h(handle, text) | Same as `re.search` |
| re.find_all_h(handle, text) | Same as `re.find_all` |
| re.find_all_strings_h(handle, text) | Same as `re.find_all_strings` |
| re.replace_h(handle, text, replacement) | Same as `re.replace` |
| re.replace_n_h(handle, text, replacement, count) | Same as `re.replace_n` |
| re.split_h(handle, text) | Same as `re.split` |
| re.count_h(handle, text) | Same as `re.count` |
More from Core Standard Library.
JSON Parse & Manipulate
Parse, build, and edit JSON. Backed by serde_json in Rust, nested get/set, merge, and pretty-print included.
File & Path I/O
Read and write files, stream large inputs, and work with paths. Blocking I/O can run on background threads.
Wall-Clock & Time Zones
Timestamps, formatting, parsing, and time zones. Built on chrono and chrono-tz, DST handled correctly.