Sign in

    regexp

    A regular expression library based on a backtracking engine.

    regexp
    regular
    expression
    Download zip
    Author
    Version
    0.3.5
    License
    Apache-2.0
    Last updated
    last year
    Downloads
    91

    No dependencies

    #RegExp

    check coverage

    A regular expression module based on a backtracking engine. Due to backtracking during matching, some regular expressions will run for a long time under specific inputs, also known as catastrophic backtracking. The design of the bytecode and interpreter was heavily inspired by the .NET regular expression library.

    #Usage

    test "basic" {
    let regexp = @regexp.compile!(
    "^(?<addr>[a-zA-Z0-9._%+-]+)@(?<host>[a-zA-Z0-9.-]+\\.[a-zA-Z]{2,})$",
    )
    let match_result = regexp.matches("12345@test.com")
    @json.inspect!(match_result.success(), content=true)
    @json.inspect!(match_result.captures(), content=[
    "12345@test.com", "12345", "test.com",
    ])
    @json.inspect!(match_result.named_captures(), content={
    "addr": "12345",
    "host": "test.com",
    })
    }

    #Features

    #Character classes

    #Assertions

    #Groups

    #Backreferences

    #Quantifiers

    #Encodings

    MatchResult

    type MatchResult

    impl Show for MatchResult

    MatchResult::captures

    fn MatchResult::captures(self : MatchResult) -> Array[String]

    MatchResult::named_captures

    fn MatchResult::named_captures(self : MatchResult) -> Map[String, String]

    MatchResult::success

    fn MatchResult::success(self : MatchResult) -> Bool

    ParseError

    pub(all) enum ParseError {
    InternalParserError
    UnmatchedGroupBegin(Int)
    UnmatchedGroupEnd(Int)
    UnmatchedGroupName(Int)
    EmptyGroupName(Int)
    EmptyGroup(Int)
    UnmatchedCharClassEnd(Int)
    UnspecifiedLoopTarget(Int)
    InvalidLoop(Int)
    LoopCountOutOfRange(Int)
    LoopMaxCountSmallerThanMinCount(Int)
    EndPatternAtEscape(Int)
    ClassMissingBracket(Int)
    GroupMissingParen(Int)
    }

    impl Eq for ParseError
    impl Show for ParseError

    RegExp

    type RegExp

    RegExp::matches

    fn RegExp::matches(self : RegExp, text : String, start~ : Int = .., end~ : Int = ..) -> MatchResult

    RegExp::pattern

    fn RegExp::pattern(self : RegExp) -> String

    captures

    fn captures(self : MatchResult) -> Array[String]

    compile

    fn compile(pattern : String) -> RegExp!Error

    matches

    fn matches(self : RegExp, text : String, start~ : Int = .., end~ : Int = ..) -> MatchResult

    named_captures

    fn named_captures(self : MatchResult) -> Map[String, String]

    pattern

    fn pattern(self : RegExp) -> String

    success

    fn success(self : MatchResult) -> Bool

    Powered by MoonBit

    Site sourceReport issuePackagesBuild queueSkillsStatistics

    © 2026 mooncakes.io