Skip to content

ECMA-262 regular expressions for every platform

The grammar and the answers of JavaScript's RegExp in fifteen languages, each held to V8's answers on the same test data: over UTF-8 and UTF-16, bounded in time and memory, with the grammar of ECMAScript 2020 and the Unicode of your choice a setting away.

Choose your language

One engine design, the same answers everywhere. Each page shows how to install it and write your first pattern.

.NET The drop-in shape of System.Text.RegularExpressions, with a source generator. dotnet add package Corvus.Regex.Ecma262 C A C ABI over the Rust engine, released as an archive for each platform. find_package(corvus_regex_ecma262) C++ A C++20 binding over the C library, built with CMake. FetchContent_MakeAvailable(corvus_regex_ecma262_cpp) Fortran A Fortran 2018 binding for gfortran and Intel ifx, with fpm and CMake. corvus_regex_ecma262_fortran = { git = "https://github.com/corvus-dotnet/corvus-regex-ecma262-fortran" } Go A pure Go port, for Go 1.25 and later. go get github.com/corvus-dotnet/corvus-regex-ecma262-go Java A Java 17 port with no dependencies. implementation("io.github.corvus-dotnet:corvus-regex-ecma262:0.1.2") Julia A pure Julia port, for Julia 1.10 and later. using Pkg; Pkg.add("CorvusRegexECMA262") Object Pascal A Free Pascal port with no dependencies, written to compile with Delphi too. fpc -Fucorvus-regex-ecma262-pas/src -Ficorvus-regex-ecma262-pas/src yourprogram.pas OCaml A native OCaml port, for OCaml 4.14 and later. opam install corvus-regex-ecma262 PHP A PHP extension for PHP 8.2 to 8.5, installed with PIE. pie install corvus-dotnet/corvus-regex-ecma262 Python A typed package with wheels for Linux, macOS and Windows, from Python 3.10. pip install corvus-regex-ecma262 R An R package, for R 4.2 and later. install.packages("corvusregexecma262", repos = c("https://corvus-dotnet.r-universe.dev", "https://cloud.r-project.org")) Ruby A gem with native builds for Linux, macOS and Windows, for Ruby 3.3 and later. gem install corvus_regex_ecma262 Rust The engine the C library and its bindings are built on, over &str and &[u16]. cargo add corvus-regex-ecma262 Swift A Swift package for Linux, macOS and iOS, over the C library. .package(url: "https://github.com/corvus-dotnet/corvus-regex-ecma262-swift", from: "0.2.3")
15
Languages, one design
29.9M
V8 answers matched, 0 wrong
UTF-8
and UTF-16, without transcoding

Built to answer as ECMAScript does

A pattern written for JavaScript, or taken from a JSON Schema, matches the same texts in every language.

📜

The answers of ECMAScript

ECMAScript 2025: lookbehind, named groups, modifier groups, Unicode property escapes, and the u and v flags. Every engine answers the whole ECMA-262 test data as V8 does, test262 included, with none wrong.

🔤

UTF-8 and UTF-16

One matcher over either encoding, with no transcoding and positions in the units of the text. Text that is not UTF-8 is refused, never read as U+FFFD.

🗓️

ECMAScript 2020 and Unicode versions

The grammar of ECMAScript 2020, which JSON Schema 2020-12 names, and the tables of Unicode 13, 17 or 18, each a setting chosen when a pattern is compiled, at no cost to a match.

⏱️

Bounded in time and memory

A backtracking matcher that remembers where a way has failed, automata for the patterns that need no backtracking, a time limit on every match, and limits of size on every pattern. No pattern can overflow the stack.

⚡

Fast searches for a start

Rare-byte literal searches, Teddy fingerprints and reverse automata find where a match can start, vectorised on x86-64 and arm64 where the language allows.

🔧

.NET: a drop-in with a generator

The shape of System.Text.RegularExpressions, zero allocation per match, and [GeneratedRegex] writing the matcher as code at build time. Read the .NET guide →

In .NET: from pattern to generated code

Put the attribute on a partial method, and the generator writes the matcher as code. The same flags, the same answers, over both encodings.

The .NET guide
using Corvus.Ecma262.RegularExpressions;

public static partial class Patterns
{
    [GeneratedRegex(@"(?<word>\w+)@(?<host>\w+)\.\w+", "gu")]
    public static partial Regex Email();
}

// Over a string
Match m = Patterns.Email().Match("mail sherlock@baker.st");
string host = m.Groups["host"].Value;                   // "baker"

// Over UTF-8, allocating nothing
ReadOnlySpan<byte> utf8 = "a@b.c and d@e.f"u8;
int n = Patterns.Email().Count(utf8);                   // 2

Ready to get started?

Choose your language, install its package, and write a pattern with ECMA-262's flags.