All Projects → ocaml → Ocaml Re

ocaml / Ocaml Re

Licence: other
Pure OCaml regular expressions, with support for Perl and POSIX-style strings

Programming Languages

ocaml
1615 projects

Projects that are alternatives of or similar to Ocaml Re

Automa.jl
A julia code generator for regular expressions
Stars: ✭ 111 (-35.47%)
Mutual labels:  regular-expression
Wayeb
Wayeb is a Complex Event Processing and Forecasting (CEP/F) engine written in Scala.
Stars: ✭ 138 (-19.77%)
Mutual labels:  regular-expression
Router
⚡️ A lightning fast HTTP router
Stars: ✭ 158 (-8.14%)
Mutual labels:  regular-expression
Regular
🔍The convenient paste of regular expression🔎
Stars: ✭ 118 (-31.4%)
Mutual labels:  regular-expression
Randexp.js
Create random strings that match a given regular expression.
Stars: ✭ 1,682 (+877.91%)
Mutual labels:  regular-expression
Regex Dos
👮 👊 RegEx Denial of Service (ReDos) Scanner
Stars: ✭ 143 (-16.86%)
Mutual labels:  regular-expression
To Regex Range
Pass two numbers, get a regex-compatible source string for matching ranges. Fast compiler, optimized regex, and validated against more than 2.78 million test assertions. Useful for creating regular expressions to validate numbers, ranges, years, etc.
Stars: ✭ 97 (-43.6%)
Mutual labels:  regular-expression
Regularexpressiondecoder
A decoder that constructs objects from regular expression matches.
Stars: ✭ 169 (-1.74%)
Mutual labels:  regular-expression
Braces
Faster brace expansion for node.js. Besides being faster, braces is not subject to DoS attacks like minimatch, is more accurate, and has more complete support for Bash 4.3.
Stars: ✭ 133 (-22.67%)
Mutual labels:  regular-expression
Find
A find-in-page extension for Chrome and Firefox that supports regular expressions.
Stars: ✭ 157 (-8.72%)
Mutual labels:  regular-expression
Tokenizer
Source code tokenizer
Stars: ✭ 119 (-30.81%)
Mutual labels:  regular-expression
Dan Jurafsky Chris Manning Nlp
My solution to the Natural Language Processing course made by Dan Jurafsky, Chris Manning in Winter 2012.
Stars: ✭ 124 (-27.91%)
Mutual labels:  regular-expression
Compile Time Regular Expressions
A Compile time PCRE (almost) compatible regular expression matcher.
Stars: ✭ 2,144 (+1146.51%)
Mutual labels:  regular-expression
Oniguruma
regular expression library
Stars: ✭ 1,643 (+855.23%)
Mutual labels:  regular-expression
Grex
A command-line tool and library for generating regular expressions from user-provided test cases
Stars: ✭ 4,847 (+2718.02%)
Mutual labels:  regular-expression
Orchestra
One language to be RegExp's Successor. Visually readable and rich, technically safe and extended, naturally scalable, advanced, and optimized
Stars: ✭ 103 (-40.12%)
Mutual labels:  regular-expression
Micromatch
Contributing Pull requests and stars are always welcome. For bugs and feature requests, please create an issue. Please read the contributing guide for advice on opening issues, pull requests, and coding standards.
Stars: ✭ 1,979 (+1050.58%)
Mutual labels:  regular-expression
Regex.persian.language
Collection of Regex for validating, filtering, sanitizing and finding Persian strings
Stars: ✭ 172 (+0%)
Mutual labels:  regular-expression
Parseback
A Scala implementation of parsing with derivatives
Stars: ✭ 168 (-2.33%)
Mutual labels:  regular-expression
Srl Php
Simple Regex Language
Stars: ✭ 1,808 (+951.16%)
Mutual labels:  regular-expression

Description

Re is a regular expression library for OCaml. Build Status

Contact

This library has been written by Jerome Vouillon ([email protected]). It can be downloaded from https://github.com/ocaml/ocaml-re

Bug reports, suggestions and contributions are welcome.

Features

The following styles of regular expressions are supported:

  • Perl-style regular expressions (module Re.Perl);
  • Posix extended regular expressions (module Re.Posix);
  • Emacs-style regular expressions (module Re.Emacs);
  • Shell-style file globbing (module Re.Glob).

It is also possible to build regular expressions by combining simpler regular expressions (module Re).

The most notable missing features are back-references and look-ahead/look-behind assertions.

There is also a subset of the PCRE interface available in the Re.Pcre module. This makes it easier to port code from that library to Re minimal changes.

Performances

The matches are performed by lazily building a DFA (deterministic finite automaton) from the regular expression. As a consequence, matching takes linear time in the length of the matched string.

The compilation of patterns is slower than with libraries using back-tracking, such as PCRE. But, once a large enough part of the DFA is built, matching is extremely fast.

Of course, for some combinations of regular expression and string, the part of the DFA that needs to be build is so large that this point is never reached, and matching will be slow. This is not expected to happen often in practice, and actually a lot of expressions that behaves badly with a backtracking implementation are very efficient with this implementation.

The library is at the moment entirely written in OCaml. As a consequence, regular expression matching is much slower when the library is compiled to bytecode than when it is compiled to native code.

Here are some timing results (Pentium III 500Mhz):

  • Scanning a 1Mb string containing only as, except for the last character which is a b, searching for the pattern aa?b (repeated 100 times):

    • RE: 2.6s
    • PCRE: 68s
  • Regular expression example from http://www.bagley.org/~doug/shootout/ [1]

    • RE: 0.43s
    • PCRE: 3.68s

    [1] this page is no longer up but is available via the Internet Archive http://web.archive.org/web/20010429190941/http://www.bagley.org/~doug/shootout/bench/regexmatch/

  • The large regular expression (about 2000 characters long) that Unison uses with my preference file to decide whether a file should be ignored or not. This expression is matched against a filename about 20000 times.

    • RE: 0.31s
    • PCRE: 3.7s However, RE is only faster than PCRE when there are more than about 300 filenames.
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].