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 . * + ? ( ) [ ] { } | ^ $ -), Unicode property escapes \p{...} \P{...} (general categories like L/Lu/Nd, and the ASCII-only POSIX classes like Alpha/Digit - see UnicodeCategories; script/block properties are unsupported), ., char classes [...] [^...] with ranges, nested shorthand escapes ([\da-f]), nested subclasses, and && intersection ([a-z&&[^aeiou]]) (\b inside a class means backspace, matching Java), alternation |, capturing groups (...), named groups (?...), non-capturing groups (?:...), lookahead (?=...) (?!...), the i inline flag (?i) (?-i) (?i:...) (?-i:...) (ASCII-only case folding, matching Java's CASE_INSENSITIVE without UNICODE_CASE), quantifiers * + ? {n} {n,} {n,m} (bounds capped at Regex.maxRepeatBound), anchors ^ $ \A \Z \z.

Capturing/named groups are recognized structurally (numbered/named correctly - see Regex.Group) but their captured spans aren't extractable yet - that's tracked separately, same as Regex's own doc comment notes.

Unsupported: word-boundary anchors \b \B, \G, lookbehind, backreferences \1..\9 \k \g{...}, Unicode script/block properties (\p{IsGreek}, \p{InGreek}, etc.), grapheme clusters \X, other inline flags ((?m), (?s), (?d), (?u), (?x), (?U)). Any other undefined letter escape (e.g. \m, \y, \q) is rejected as invalid syntax, matching java.util.regex.Pattern's own behavior.

Attributes

Source
RegexParser.scala
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

Source
RegexParser.scala