RegexParser

halotukozak.regex.RegexParser
object RegexParser

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

Graph
Supertypes
class Object
trait Matchable
class Any
Self type

Members list

Value members

Concrete methods

def parse(pattern: String): Either[RegexParseError, Regex]

Parse pattern into a Regex. Returns Left with structured error info if the pattern is malformed or uses an unsupported feature.

Parse pattern into a Regex. Returns Left with structured error info if the pattern is malformed or uses an unsupported feature.

Attributes