Skip to content

std.text.search

Search is the gateway from filesystem to stream. Typed results. Ordered parallelism.

std.text.search provides filesystem walking and pattern search, grafted from the proven ripgrep engine and integrated with std.text.stream.


walk(p"src/")
|> search(r/func \w+/)
|> map(match => "${match.path}:${match.line}: ${match.text}")
|> for_each(println)

struct SearchConfig {
ignore_git: bool = true,
ignore_hidden: bool = true,
follow_symlinks: bool = false,
binary_detection: bool = true,
max_depth: ?u32 = null,
}
struct SearchMatch {
path: Path,
line: u64,
column: u64,
text: String,
}
struct SearchCaptureMatch {
path: Path,
line: u64,
column: u64,
text: String,
# Named capture groups as struct fields
}

# Default config
walk(p"src/")
# Explicit config
walk(p"src/", SearchConfig{
ignore_git: true,
ignore_hidden: false,
max_depth: 5,
})
# Modifier methods
walk(p"src/")
|> respect_gitignore(true)
|> respect_hidden(false)
|> with_max_depth(3)

# Basic search
walk(p"src/") |> search(r/func \w+/)
# Search with typed captures
walk(p"src/") |> search_with_captures(r/(?<name>\w+)\s*\((?<params>[^)]*)\)/)
# Case sensitivity
walk(p"src/") |> search(r/ERROR/, case_sensitive: true)

# Ordered (default) — deterministic output
walk(p"src/") |> search(r/pattern/) |> parallel(4)
# Unorderedfaster but nondeterministic
walk(p"src/") |> search(r/pattern/) |> parallel_unordered(4)

Search results feed into the stream pipeline:

walk(p"src/")
|> search(r/func/)
|> map($_.text)
|> unique()
|> count()

Or use the stream literal:

<<walk(p"src/")>>
|> search(r/func/)
|> map($_.text)

walk(p"src/")
|> search_with_captures(r/(?<type>struct|func)\s+(?<name>\w+)/)
|> for_each(m =>
print("${m.type} ${m.name}")
)

FeatureJanus searchripgrep CLIgrep (Unix)
Type safety✅ Static types
Typed captures✅ Struct fields
Stream integration✅ `>` pipeline⚠️
$1 ergonomics:script
Ordered parallel✅ Default
Graft engine✅ ripgrep


Search: the gateway from filesystem to stream.