A symbolic regex algebra with exact language containment ("is this pattern a subset of that one?") in addition to the usual construction combinators — not just string matching. Pure Scala, no java.util.regex (or any other JVM-only API) anywhere in the implementation, so it compiles and runs identically on the JVM, Scala.js, and Scala Native.
Construct via smart factories on the companion (Regex.lit, Regex.literal, Regex.range, Regex.apply, Regex.alt, Regex.inter, Regex.all) and member combinators (a concat b, a | b, a & b, !a, r.star, r.repeat(n, m)). Raw case class constructors are inaccessible — only pattern matching via the generated unapply methods is allowed.
Supports literals, escapes (\d \D \s \S \w \W \t \n \r \f \a \e \v \cX \0[n[n]] \xhh \x{h...h} \uhhhh \Q...\E \R and meta-escapes), Unicode property escapes \p{...} \P{...} (general categories and ASCII-only POSIX classes; see UnicodeCategories), character classes (including ranges, negation, nested subclasses, and && intersection), ., alternation |, capturing groups (...), named groups (?...), non-capturing groups (?:...), lookahead (?=...) (?!...), the i inline flag (?i) (?-i) (?i:...) (?-i:...), anchors ^ $ \A \Z \z, quantifiers * + ? {n} {n,} {n,m} (bounds capped at Regex.maxRepeatBound).
Capturing groups are recognized structurally (numbered/named correctly, and fully transparent to every containment/matching operation - see Regex.Group and Subset's doc comment) but their captured spans aren't extractable yet - that's tracked separately.
Unsupported (parser returns RegexParseError.UnsupportedFeature): word-boundary anchors \b \B, \G, lookbehind (? \g{...}, Unicode script/block properties (\p{IsGreek}, \p{InGreek}), grapheme clusters \X.
For subset/emptiness/nullability queries and Brzozowski derivatives, see Subset.
Attributes
- Companion
- object
- Source
- Regex.scala
- Graph
-
- Supertypes
-
trait Enumtrait Serializabletrait Producttrait Equalsclass Objecttrait Matchableclass Any