# @bufbuild/re2

> An RE2-compatible regex engine tailored for CEL and Protovalidate

Latest version **0.6.1** (published 2026-08-27) · MIT license · 0 weekly downloads

## Install

```sh
npm install @bufbuild/re2
pnpm add @bufbuild/re2
yarn add @bufbuild/re2
bun add @bufbuild/re2
```

## Health

**Score 75/100 (B)** — status: active.

Positive: has types; esm support; no vulnerabilities; has provenance; recently updated; high maintenance score; high quality score.

Warnings: low downloads; pre 1.0.

## Facts

| | |
|---|---|
| Version | 0.6.1 |
| Published | 2026-08-27 |
| First published | 2026-05-19 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 0 |
| Unpacked size | 399.2 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Provenance | attested (GitHub Actions) |
| GitHub stars | 39 |
| Maintainers | bufdev, tstamm-buf, bufbot, jdailey_buf, doriakeung, cmahony |
| Keywords | javascript, typescript, protobuf, cel, common-expression-language |

## Links

- npm: https://www.npmjs.com/package/@bufbuild/re2
- Repository: https://github.com/bufbuild/cel-es
- Homepage: https://github.com/bufbuild/cel-es#readme
- Issues: https://github.com/bufbuild/cel-es/issues
- npm.io page: https://npm.io/package/@bufbuild/re2

## Alternatives

- [@openai/codex-sdk](https://npm.io/package/@openai/codex-sdk.md) — 731.4K weekly downloads
- [babel-plugin-transform-react-jsx](https://npm.io/package/babel-plugin-transform-react-jsx.md) — 565.0K weekly downloads
- [babel-helper-remove-or-void](https://npm.io/package/babel-helper-remove-or-void.md) — 508.5K weekly downloads
- [@pnpm/store-controller-types](https://npm.io/package/@pnpm/store-controller-types.md) — 186.9K weekly downloads
- [react-native-signature-canvas](https://npm.io/package/react-native-signature-canvas.md) — 155.6K weekly downloads

## Recent versions

- 0.6.1 (latest) — 2026-08-27
- 0.0.1-alpha.1 (alpha) — 2026-05-19
- 0.6.0 — 2026-06-01

## README

# @bufbuild/re2

This package provides an [RE2-compatible](https://cel.dev) regular expression engine, designed for use with CEL-es and Protovalidate-es.

## Usage

```ts
import { RE2JS } from '@bufbuild/re2';

const re = new RE2JS('^foo');
console.log(re.test('foo')); // true
console.log(re.testExact('fooxyz')); // false

console.log(RE2JS.matches('^foo','foo')); // true
```

## Limitations
Only boolean matchers are supported: `test` and `testExact`.

The instance method `matches` is an alias for `testExact`. The static method `RE2JS.matches` compiles 
a regular expression and calls `testExact`.

As a size optimization, Unicode category and script information is generated on first use. This causes a 
slight slowdown the first time a pattern is compiled with a category or script (only the referenced category 
or script is generated). The categories and scripts in Unicode version 16.0 are supported. This package includes
data to support Unicode version 16.0 on Unicode 15.0 or later.

## Credits
This code is a fork of the [RE2JS](https://re2js.leopard.in.ua) project. It has been converted to TypeScript and has a feature set tailored for
CEL and Protovalidate-es.

---
_Source: https://npm.io/package/@bufbuild/re2 · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
