halotukozak.regex

Members list

Type members

Classlikes

enum Regex

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.

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), character classes (including ranges and negation), ., alternation |, non-capturing-style groups (...), quantifiers * + ? {n} {n,} {n,m} (bounds capped at Regex.maxRepeatBound).

Unsupported (parser returns RegexParseError.UnsupportedFeature): anchors ^ $ \b \B \A \Z \z \G, lookaround (?= (?! (? \g{...}, Unicode properties \p{...}, grapheme clusters \X.

For subset/emptiness/nullability queries and Brzozowski derivatives, see Subset.

Attributes

Companion
object
Supertypes
trait Enum
trait Serializable
trait Product
trait Equals
class Object
trait Matchable
class Any
Show all
object Regex

Attributes

Companion
enum
Supertypes
trait Sum
trait Mirror
class Object
trait Matchable
class Any
Self type
Regex.type
sealed trait RegexParseError

Reason a RegexParser.parse call did not produce a Regex.

Reason a RegexParser.parse call did not produce a Regex.

Attributes

Companion
object
Supertypes
class Object
trait Matchable
class Any
Known subtypes

Attributes

Companion
trait
Supertypes
trait Sum
trait Mirror
class Object
trait Matchable
class Any
Self type
object RegexParser

Java-regex-style parser producing a normalized Regex.

Java-regex-style parser producing a normalized Regex.

Supported subset (see Regex doc): 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 . * + ? ( ) [ ] { } | ^ $ -), ., char classes [...] [^...] with ranges (\b inside a class means backspace, matching Java), alternation |, groups (...) (capturing or (?:...), flag groups are NOT supported), quantifiers * + ? {n} {n,} {n,m} (bounds capped at Regex.maxRepeatBound).

Unsupported: anchors ^ $ \b \B \A \Z \z \G, lookaround, backreferences \1..\9 \k \g{...}, Unicode properties \p{...}, grapheme clusters \X, named groups, flag groups. Any other undefined letter escape (e.g. \m, \y, \q) is rejected as invalid syntax, matching java.util.regex.Pattern's own behavior.

Known gaps relative to java.util.regex.Pattern (tracked, not yet implemented):

  • in-class intersection [a-z&&[^g-p]] is silently misparsed as literal chars instead of being rejected or computing the intersection
  • shorthand classes nested inside a character class, e.g. [\d.], are rejected outright instead of being unioned into the class like Java does

Attributes

Supertypes
class Object
trait Matchable
class Any
Self type
object Subset

Attributes

Supertypes
class Object
trait Matchable
class Any
Self type
Subset.type

Types

opaque type Subset

Opaque view over a Regex exposing Brzozowski-derivative based language emptiness and subset operations.

Opaque view over a Regex exposing Brzozowski-derivative based language emptiness and subset operations.

a.subset(b) decides whether L(a) ⊆ L(b) by checking emptiness of a ∩ ¬b. Termination relies on smart-constructor normalization in Regex keeping the derivative state set finite up to similarity.

Attributes