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.
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")
println(match_result.success()) // true
println(match_result.captures()) // ["12345@test.com", "12345", "test.com"]
println(match_result.named_captures()) // {"addr": "12345", "host": "test.com"}
- Character range
- Escapes (e.g.
\d,\D,\s,\S,\w,\W)
- Begin of input
- End of input
- Word boundary
- Lookaround
- Capturing group
- Non-capturing group
- Named capturing group
- Group backreference
- Named backreference
- Zero or more (*)
- Zero or one (?)
- One or more (+)
- Range ({n}, {n,}, {n, m})
- Non-greedy
- Unicode