reni

Search:
Group by:

reni - A regular expression engine compatible with Oniguruma

A pure Nim regex engine that replicates the syntax and semantics of Oniguruma.

Features

  • Capture groups (numbered and named)
  • rfCaptureGroup for TextMate-compatible mixed capture numbering
  • Backreferences and named backreferences with recursion-level support
  • Lookaround assertions (lookahead, lookbehind, negative variants)
  • Atomic groups (?>...)
  • Conditionals (?(cond)yes|no)
  • Subexpression calls \g<name>, \g<n>
  • Absent operator (?~...)
  • POSIX character classes, Unicode properties \p{...}
  • Greedy, lazy, and possessive quantifiers
  • Grapheme cluster mode (?y{g}), word mode (?y{w})
  • Flags: (?i), (?m), (?x), (?W), (?D), (?S), (?P), (?I), (?L)
  • ReDoS protection via step limit

Basic usage

import pkg/reni

let m = search("hello world", re("(\\w+)\\s(\\w+)"))
assert m.found
assert m.boundaries[0] == 0 .. 11  # full match
assert m.boundaries[1] == 0 .. 5   # group 1
assert m.boundaries[2] == 6 .. 11  # group 2

See the project README for more examples including named captures, matchAt, findAll, replace, split, and backward search.

Modules

  • types — Core type definitions shared across the engine. Regex, Match, Span and the flags reach callers through this package; the AST and the matcher's tables only by importing reni/types directly.
  • compiler — Pattern compilation entry point. Exposes re(pattern, flags) which parses, validates, and optimizes a pattern into a reusable Regex.
  • api — High-level matching API: search, searchBackward, matchAt, findAll, replace, split, plus Match / capture-group accessors.