Legivel


RegexDSL

Namespace: Legivel.Utilities

Nested types and modules

TypeDescription
MatchResult

MatchResult of a regex match

ParseOutput
ParseResult
RGXType

Contains a Regular Expression

Functions and values

Function or valueDescription
Advance(arg1, arg2)
Signature: (string * string) -> string

Returns rest-string, where match 'm' is removed from source 's'

AssesInput arg1 arg2
Signature: RollingStream<TokenData> -> RGXType -> ParseOutput

Primary input assesment, rough input match (at token-level), if match, return the input that matched

AssesInputPostParseCondition(...)
Signature: (RollingStream<TokenData> * TokenData -> bool) -> RollingStream<TokenData> -> RGXType -> ParseOutput

Primary input assesment with Post-Parse condition. The condition is checked after each RGP token/char.

DecodeEncodedEscapedCharacters(arg1)
Signature: string -> string

Converts string-literal encoded escape characters as "\n" to the char they represent

DecodeEncodedHexCharacters(arg1)
Signature: string -> string

Converts string-literal encoded hex characters as "\x00" to the char they represent

DecodeEncodedUnicodeCharacters(arg1)
Signature: string -> string

Converts string-literal encoded unicode characters as "\u0000" or "\U00000000" to the char they represent

DecodeEncodedUriHexCharacters(arg1)
Signature: string -> string

Converts uri encoded hex characters as "%00" to the char they represent

GRP(arg1)
Signature: RGXType -> RGXType

Creates Regex group, eg GRP(RGP("abc")) := (abc)

HasMatches(arg1, arg2)
Signature: (RollingStream<TokenData> * RGXType) -> bool * string

Checks for matches of pattern p in string s. If matched, returns (true, ), otherwise (false, "")

IsMatch(arg1, arg2)
Signature: (RollingStream<TokenData> * RGXType) -> bool

Returns whether pattern p matches on string s

IsMatchStr(arg1, arg2)
Signature: (string * 'a) -> bool
Type parameters: 'a

Returns whether pattern p matches on string s

Match(arg1, arg2)
Signature: (string * 'a) -> string list
Type parameters: 'a

Returns list of match groups, for pattern p on string s

NOT(arg1)
Signature: RGXType -> RGXType

Exclude Set regex pattern, eg: NOT(RGO("a-zA-Z")) := [^a-zA-Z]

OOM(arg1)
Signature: RGXType -> RGXType

Regex pattern may repeat once or more, eg: OOM(RGP("abc")) := (abc)+

OOMNG(arg1)
Signature: RGXType -> RGXType

Regex pattern may repeat once or more - non greedy, eg: OOM(RGP("abc")) := (abc)+

OPT(arg1)
Signature: RGXType -> RGXType

Make Regex optional, eg: OPT(RGP("abc")) := (abc)?

Range(arg1, arg2, arg3)
Signature: (RGXType * int * int) -> RGXType

Regex pattern may repeat within given range, eg: Range(RGP("abc"), 2, 3) := (abc){2,3}

Repeat(arg1, arg2)
Signature: (RGXType * int) -> RGXType

Regex pattern must repeat exactly given value, eg: Range(RGP("abc"), 2) := (abc){2}

RGO(arg1, arg2)
Signature: (string * Token list) -> RGXType

One in Set regex pattern, eg: RGO("a-zA-Z") := [a-zA-Z]

RGP(arg1, arg2)
Signature: (string * Token list) -> RGXType

Plain regex pattern, eg: RGP("abc") := abc

RGS(arg1)
Signature: 'a -> string
Type parameters: 'a

Regex ToString - match from string start

RGSF(arg1)
Signature: 'a -> string
Type parameters: 'a

Regex ToString - full string match

RGSFR(arg1)
Signature: 'a -> string
Type parameters: 'a

Regex ToString - match anywhere in the string (FR = free)

TokenDataToString(arg1)
Signature: ParseOutput -> string option

Matched tokens to matched string

ZOM(arg1)
Signature: RGXType -> RGXType

Regex pattern may repeat zero or more, eg: ZOM(RGP("abc")) := (abc)*

ZOMNG(arg1)
Signature: RGXType -> RGXType

Regex pattern may repeat zero or more - nongreedy, eg: ZOM(RGP("abc")) := (abc)*

Active patterns

Active patternDescription
( |Regex|_| ) arg1 arg2
Signature: string -> string -> string list option

Regex Active pattern to match string pattern on string input, and returns a list of matches

CompiledName: |Regex|_|

( |Regex2|_| ) arg1 arg2
Signature: RGXType -> RollingStream<TokenData> -> MatchResult option

Regex Active Pattern to match RGXType pattern on string input, and returns a match result

CompiledName: |Regex2|_|

Fork me on GitHub