Steven Levithan's Avatar

Steven Levithan

@slev.life

Creator → Regex+, Oniguruma-To-ES, xregexp.com, regex.cool Coauthor → Regular Expressions Cookbook, High Performance JavaScript slev.life

214
Followers
16
Following
60
Posts
08.11.2024
Joined
Posts Following

Latest posts by Steven Levithan @slev.life

Preview
GitHub - slevithan/regex: JS regexes ➕ future. A template tag for readable, high-performance, native JS regexes with extended syntax, context-aware interpolation, and always-on best practices. JS regexes ➕ future. A template tag for readable, high-performance, native JS regexes with extended syntax, context-aware interpolation, and always-on best practices. - slevithan/regex

Regex+ 6.1.0 released. Adds even cleaner and more robust interpolation of RegExp instances and partial patterns. And improved docs. 😀 github.com/slevithan/re...

09.12.2025 01:55 👍 0 🔁 0 💬 0 📌 0

Oniguruma-To-ES now has 12M dl/m. Most of that comes from Shiki, which uses it to make VSCode-style syntax highlighting possible in native JS (no large WASM). I like to think it's contributing to Shiki's rapid growth :) Recent example is in Vercel's streamdown.ai

21.11.2025 19:09 👍 0 🔁 1 💬 0 📌 0

Neither @antfu.me nor I thought this was possible when we started down this road. But it's finally done 😁

02.08.2025 16:57 👍 5 🔁 1 💬 0 📌 0

Great tips

27.06.2025 17:16 👍 2 🔁 0 💬 0 📌 0
Preview
GitHub - slevithan/regex-colorizer: 🎨 Highlighter for JavaScript regex syntax 🎨 Highlighter for JavaScript regex syntax. Contribute to slevithan/regex-colorizer development by creating an account on GitHub.

The latest version of Regex Colorizer (a project I started in 2007) is finally available via npm, after getting the package name transferred to me 😊 github.com/slevithan/re...

07.05.2025 10:57 👍 2 🔁 0 💬 0 📌 0

Thanks so much @brc-dd.dev for the generous sponsorship!! Appreciate all the great work you do for VitePress and open source!

04.05.2025 00:15 👍 2 🔁 0 💬 1 📌 0
Preview
GitHub - slevithan/regex-recursion: Recursive regex matching in JavaScript. Official Regex+ plugin. Recursive regex matching in JavaScript. Official Regex+ plugin. - slevithan/regex-recursion

Improved the docs for regex-recursion, highlighting standalone usage (without Regex+). Less than 2 kB for recursive regex matching with support for all ES2025 regex syntax. github.com/slevithan/re...

03.05.2025 11:46 👍 0 🔁 0 💬 0 📌 0

🚢 Released emoji-regex-xs v2.0. Now matches all underqualified emoji included in Unicode's emoji-test.txt list, to better match @mths.be's excellent emoji-regex and real-world emoji use. Lib size reduced from 0.3 to 0.2 kB in the process :)

21.04.2025 18:08 👍 2 🔁 0 💬 0 📌 0
Preview
Don't expand character match length with flag `i` (unless using a new flag) · Issue #351 · kkos/oniguruma Currently, Oniguruma sometimes applies Unicode's SpecialCasing.txt rules when using flag i, which can lengthen the match of a character, character class, or set (like \w or \S). For example, (?i)^ß...

Regular expressions should not change the length of a match based on case insensitivity. My case for a breaking change in Oniguruma: github.com/kkos/oniguru...

19.04.2025 14:27 👍 0 🔁 0 💬 0 📌 0
Preview
GitHub - slevithan/oniguruma-to-es: Convert patterns from Oniguruma (the regex engine used by Ruby, TextMate grammars, etc.) to native JavaScript RegExp Convert patterns from Oniguruma (the regex engine used by Ruby, TextMate grammars, etc.) to native JavaScript RegExp - slevithan/oniguruma-to-es

oniguruma-to-es v4.2.0 shipped! 🚢 Continues improving by far the most sophisticated regex translator in the world. JS coders who've never used Oniguruma might still find it useful if they want much more feature-rich regexes (with native perf!) github.com/slevithan/on...

13.04.2025 19:39 👍 0 🔁 0 💬 0 📌 0

I hit this too. It's fixed now, but at the time, `npm login` fixed it for me (the 404 was a misleading message).

12.04.2025 04:10 👍 2 🔁 0 💬 1 📌 0

oniguruma-parser v0.10.0 brings a bunch of quality of life improvements. 🚀 The regex optimizer it includes, which is probably the most interesting part for people who don't regularly use Oniguruma, has continued to improve! github.com/slevithan/on...

11.04.2025 02:12 👍 0 🔁 0 💬 0 📌 0

Any React Native devs, can you help me by testing whether Regex+ works at all in RN 0.75.1+ or RN 0.74.6+? 🙏🏻😌 Related issue: github.com/slevithan/re...

06.04.2025 11:08 👍 1 🔁 0 💬 0 📌 0

Migrated a bunch of tests from Jasmine to Vitest so I could use TypeScript more easily. Super nice! ⚡ Will be trying to use Vitest everywhere from now on.

05.04.2025 22:31 👍 4 🔁 0 💬 0 📌 0

Over the last week and with major help from RedCMD, we converted all of oniguruma-parser from JS to TS. 🎉 Surprised that all of this work uncovered 0 bugs (despite the high complexity of the migrated code), which I think speaks to the pre-existing high quality of the lib. github.com/slevithan/on...

27.03.2025 00:14 👍 2 🔁 0 💬 0 📌 0
Preview
Pre-optimize TM grammars for performance and reduced bundle size · Issue #243405 · microsoft/vscode TextMate grammars used for syntax highlighting can individually contain thousands of regexes and are, collectively, quite large. Their regexes can be optimized via minification that also improves t...

Request to run VS Code's syntax highlighting grammars through my Oniguruma regex optimizer (like Shiki does), which would improve highlighting performance for some languages like C++ and reduce the size of VS Code: github.com/microsoft/vs...

13.03.2025 00:17 👍 1 🔁 0 💬 0 📌 0

Just shipped version 0.6 of oniguruma-parser, which includes a new optimization that is able to automatically identify and fix some ReDoS vulnerabilities without changing what the regex matches. It already identified one such regex in the Haskell grammar used by @shiki.style

11.03.2025 09:45 👍 1 🔁 0 💬 0 📌 0

Although it's not in the release notes, @shiki.style 3.2.0 includes slight-to-major performance improvements for many languages (for both the Oniguruma and JS engines), thanks to the new regex optimizer from `oniguruma-parser`. Worth upgrading!

11.03.2025 03:05 👍 1 🔁 0 💬 0 📌 0
Preview
feat: use oniguruma-parser/optimizer for all grammars by slevithan · Pull Request #133 · shikijs/textmate-grammars-themes Closes #125. Introduces a fancy Oniguruma regex optimizer that not only minifies more robustly (e.g., C++ drops more than 35,000 characters compared to the existing minification), but also improves...

Adding my new regex optimizer to @shiki.style: github.com/shikijs/text... - It shaves more than 35,000 chars off just the C++ grammar (as an example) compared to the prior minification (without any change in meaning), and makes some of its regexes significantly faster ⚡🚀

09.03.2025 19:41 👍 2 🔁 0 💬 0 📌 0
Post image

More oniguruma-parser updates! An example of what it's optimizer/minifier can do, in the image. Some transforms can significantly improve perf for complex regexes 🚀

06.03.2025 22:21 👍 1 🔁 0 💬 0 📌 0

Lots of improvements released for my new Oniguruma optimizer (minifies regexes and improves their perf), plus added a new demo page: github.com/slevithan/on...

05.03.2025 20:59 👍 2 🔁 0 💬 0 📌 0
oniguruma-parser/src/optimizer at main · slevithan/oniguruma-parser Parse Oniguruma regular expressions. Contribute to slevithan/oniguruma-parser development by creating an account on GitHub.

New launch! `oniguruma-parser` extracts the parser/traverser from my Oniguruma-To-ES transpiler, makes a ton of improvements, and adds new code generator and optimizer modules: github.com/slevithan/on... Great for TextMate grammar authors and anyone who works with Oniguruma regexes

03.03.2025 19:12 👍 0 🔁 0 💬 0 📌 0

Oniguruma-To-ES v3.1.0 includes a new feature I think is new in JS: Lazy construction of RegExp objects, deferred until first use in a search (with nothing observably different before/after). Also allows lazy-compile based on pattern length, since only very long patterns are slow to construct in V8

04.02.2025 03:19 👍 2 🔁 0 💬 0 📌 0

Using Oniguruma → JavaScript regex transpilation in VS Code for syntax highlighting is getting community support: github.com/microsoft/vs... Add a thumbs up on the issue if you think it's a good idea 😊

23.01.2025 00:03 👍 0 🔁 0 💬 0 📌 0

Cool 😊 I saw you mentioned its possessive quantifiers before, too. Happy to answer any questions, and very open to any feedback

22.01.2025 03:06 👍 1 🔁 0 💬 0 📌 0

Here's the same exact thing but readable/maintainable, using Regex+ (can be minified to a regex literal using its Babel plugin).

22.01.2025 01:13 👍 4 🔁 1 💬 1 📌 0

Yeah, it's helpful (and accurate) to think of all assertions (^, $, \b, \B, lookaround) as matching an empty string at their qualifying positions.

17.01.2025 22:49 👍 2 🔁 0 💬 0 📌 0

oniguruma-to-es hits a big milestone with v2.0 by comprehensively supporting the extremely flexible \G anchor (which has no direct equivalent in JS regexes). See github.com/slevithan/on...

14.01.2025 22:39 👍 1 🔁 0 💬 0 📌 0
Preview
Ideas for creating a universal regex translator · Issue #27 · slevithan/oniguruma-to-es This project (oniguruma-to-es) and it's high complexity demonstrates that accurately/comprehensively converting between any two regex flavors is a hard task, and not for the faint of heart. (Though...

Ever wondered why there aren't good tools for converting between different regex flavors automatically?
Would you use a universal regex translator in your own projects?
Want to help build one?
github.com/slevithan/on...

09.01.2025 19:30 👍 1 🔁 0 💬 0 📌 0
Preview
GitHub - slevithan/oniguruma-to-es: Convert patterns from Oniguruma (the regex engine used by Ruby, TextMate grammars, etc.) to native JavaScript RegExp Convert patterns from Oniguruma (the regex engine used by Ruby, TextMate grammars, etc.) to native JavaScript RegExp - slevithan/oniguruma-to-es

oniguruma-to-es v1.0.0 is out! ✨ The new release includes lots of edge case fixes reported by Oniguruma expert RedCMD, making its emulation even more accurate github.com/slevithan/on...

08.01.2025 15:23 👍 0 🔁 0 💬 0 📌 0