Sign in

Steven Levithan

@slev.life
217 followers 16 following 60 posts

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

PostsRepliesMedia
Steven Levithan @slev.life · 09/12/2025
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...
github.com
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
000
Steven Levithan @slev.life · 21/11/2025
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
001
Steven Levithan @slev.life · 02/08/2025
Neither @antfu.me nor I thought this was possible when we started down this road. But it's finally done 😁
051
Steven Levithan @slev.life · 27/06/2025
Great tips
010
Steven Levithan @slev.life · 07/05/2025
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...
github.com
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.
010
Steven Levithan @slev.life · 04/05/2025
Thanks so much @brc-dd.dev for the generous sponsorship!! Appreciate all the great work you do for VitePress and open source!
110
Steven Levithan @slev.life · 03/05/2025
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...
github.com
GitHub - slevithan/regex-recursion: Recursive regex matching in JavaScript. Official Regex+ plugin.
Recursive regex matching in JavaScript. Official Regex+ plugin. - slevithan/regex-recursion
000
Steven Levithan @slev.life · 21/04/2025
🚢 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 :)
010
Steven Levithan @slev.life · 19/04/2025
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...
github.com
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)^ß...
000
Steven Levithan @slev.life · 13/04/2025
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...
github.com
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
000
Steven Levithan @slev.life · 11/04/2025
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...
000
Steven Levithan @slev.life · 06/04/2025
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...
000
Steven Levithan @slev.life · 05/04/2025
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.
040
Steven Levithan @slev.life · 27/03/2025
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...
020
Steven Levithan @slev.life · 13/03/2025
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...
github.com
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...
010
Steven Levithan @slev.life · 11/03/2025
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
010
Steven Levithan @slev.life · 11/03/2025
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!
010
Steven Levithan @slev.life · 09/03/2025
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 ⚡🚀
github.com
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...
020
Steven Levithan @slev.life · 06/03/2025
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 🚀
010
Steven Levithan @slev.life · 05/03/2025
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...
github.com
020
Steven Levithan @slev.life · 03/03/2025
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
github.com
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.
000
Steven Levithan @slev.life · 04/02/2025
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
020
Steven Levithan @slev.life · 23/01/2025
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 😊
000
Steven Levithan @slev.life · 22/01/2025
Here's the same exact thing but readable/maintainable, using Regex+ (can be minified to a regex literal using its Babel plugin).
141
Steven Levithan @slev.life · 14/01/2025
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...
010
Steven Levithan @slev.life · 09/01/2025
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...
github.com
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...
010
Steven Levithan @slev.life · 08/01/2025
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...
github.com
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
000
Steven Levithan @slev.life · 05/01/2025
What do you think github.com/slevithan/re... is missing that would make it easier to use or make regexes in JavaScript better?
github.com
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
040
Reposted by Steven Levithan
Anthony Fu @antfu.me · 31/12/2024
In 2024, we have redistributed a total of $4,371.83 USD to the open-source community! Thanks to everyone who supported this idea! 💖 Here is the recap: opencollective.com/antfu/update...
opencollective.com
Anthony Fu Fund Redistribution, 2024 Recap - Anthony Fu Fund
Hello everyone, we hope you had a wonderful holiday and a fantastic year! Since we started this Initiative on Spo...
312211
Steven Levithan @slev.life · 29/12/2024
JavaScript regexes got most things right (and are better with flag u/v), but there were a handful of deep mistakes in behavior/API (some inherited but mostly breaks from prior art in Perl, etc.). After deep-diving into Oniguruma edge cases… good god, it could have been much worse
130
Steven Levithan @slev.life · 29/12/2024
The biggest improvement most people can make to their mastery of regex is usually not learning more advanced features, but truly understanding *backtracking* This short article of mine from 2007 illustrates in depth the mechanics of regex backtracking: blog.stevenlevithan.com/archives/gre...
blog.stevenlevithan.com
Performance of Greedy vs. Lazy Regex Quantifiers
A common misconception about regular expression performance is that lazy quantifiers (also called non-greedy, reluctant, minimal, or ungreedy) are faster than their greedy equivalents. That's generall...
000
Steven Levithan @slev.life · 27/12/2024
The path to supporting 100% of TextMate grammars in @shiki.style's JS engine: github.com/shikijs/shik...
github.com
Path to supporting 100% of grammars in the JS engine · Issue #876 · shikijs/shiki
Shiki's JS engine uses Oniguruma-To-ES under the hood to emulate Oniguruma regexes. As of the latest version, the vast majority of grammars (which contain dozens to thousands of regexes each) are s...
051
Steven Levithan @slev.life · 27/12/2024
Just shipped 3 library updates. 2024 saw a lot of OSS 🚢ing: New libs Regex+ (plus related babel-plugin-transform-regex, regex-recursion, regex-utilities), Oniguruma-To-ES, Awesome Regex, and emoji-regex-xs, plus new major versions of parseUri and Regex Colorizer. Can you guess the theme? 🤔
081
Steven Levithan @slev.life · 24/12/2024
Would you use a JS library that added an optional timeout for regexes and worked in Node and browsers? Considering adding this to Regex+
021
Steven Levithan @slev.life · 24/12/2024
Started late, but wrote more open source code this year than any other year before:
010
Steven Levithan @slev.life · 21/12/2024
.@shiki.style's JS engine has continually improved since being introduced in v1.15. As of the just-launched v1.24.4, it's no longer experimental! 🎉 The JS engine allows dropping the large Oniguruma WASM dependency while still sharing the same syntax highlighting grammars used by VS Code, GitHub, etc
250
Steven Levithan @slev.life · 19/12/2024
oniguruma-to-es v0.8 is now the best regex flavor→flavor translator in the world. Tell me if you disagree! Accurately translates 99.9% of real-world Oniguruma regexes, and it's hard to find any 2 regex flavors with more complex and nuanced differences than Oniguruma & JS. Will continue improving!
001
Steven Levithan @slev.life · 19/12/2024
🎉 oniguruma-to-es 0.8.0 released, adding another large chunk of hard-fought grammars to @shiki.style's supported list when using its lightweight JS engine (which is < 4% of the size of the WASM regex engine). 95% of all grammars (> 99.9% of all regexes) now supported. github.com/slevithan/on...
github.com
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
030
Steven Levithan @slev.life · 09/12/2024
Longtime fan of @dr-axel.de's books and work. Welcome to 🦋
041
Steven Levithan @slev.life · 01/12/2024
Thanks for the sponsorship! 🙏
030
Steven Levithan @slev.life · 22/11/2024
The JS engine for @shiki.style improves yet again with the latest version of oniguruma-to-es: github.com/shikijs/shik... (+1 grammar supported, and improved perf for most grammars)
github.com
feat: bump oniguruma-to-es for grammar support and perf by slevithan · Pull Request #842 · shikijs/shiki
Updates oniguruma-to-es to v0.6.0, and makes corresponding changes. Option accuracy: &#39;loose&#39; replaced by rules.allowUnhandledGAnchors. Now implicitly using accuracy: &#39;default&#39;. ...
031
Steven Levithan @slev.life · 16/11/2024
Just released Oniguruma-To-ES v0.4.0! github.com/slevithan/on... It includes a breakthrough that will increase @shiki.style's grammar support for its JS engine from 85% of grammars to 92%. This is after v0.1.2 of my lib bumped Shiki's coverage to 85% 2 days ago 😂
141
Reposted by Steven Levithan
Shiki @shiki.style · 15/11/2024
🌈 Shiki v1.23 just dropped with massive updates: - New JavaScript engine by @slev.life that supports more languages - New Colorized Brackets package by michaelmakes.games - FS-based Twoslash cache by @nakasyou.bsky.social - New Style-to-Class transformer 👇 github.com/shikijs/shik...
github.com
Release v1.23.0 · shikijs/shiki
🚀 Features Port @michael-makes/shiki-colorized-brackets JSR package  -  by @MichaelMakesGames in #831 (94cc6) Use Oniguruma-To-ES in the JS engine  -  by @slevithan and @antfu in #828 and #832 ...
08112
Steven Levithan @slev.life · 13/11/2024
Oniguruma-To-ES v0.3.0 now supports the vast majority of ways that recursion is used, including indirect recursion and multiple recursions in the same pattern — further increasing the number of supported grammars when used with Shiki syntax highlighter. github.com/slevithan/on... cc @antfu.me
github.com
GitHub - slevithan/oniguruma-to-es: Convert patterns from Oniguruma (the regex flavor used in Ruby, TextMate grammars, etc.) to native JavaScript RegExp
Convert patterns from Oniguruma (the regex flavor used in Ruby, TextMate grammars, etc.) to native JavaScript RegExp - slevithan/oniguruma-to-es
020
Steven Levithan @slev.life · 12/11/2024
Regex+ (formerly `regex`) recently crossed 500 ⭐s, 500K mo. dls, and 5 mo. since initial release (19 releases). 🎉 This is the regex library I've wanted since ES6 added tagged templates. Try it out -- I think you'll find the "regexes are unreadable" reputation is outdated. github.com/slevithan/re...
github.com
GitHub - slevithan/regex: JS regexes + future. A template tag for readable, high-performance, native JS regexes, with context-aware interpolation and always-on best practices.
JS regexes + future. A template tag for readable, high-performance, native JS regexes, with context-aware interpolation and always-on best practices. - slevithan/regex
000
Steven Levithan @slev.life · 11/11/2024
Uplevel your regex-fu with my deep dive into JS regex history on Smashing Magazine. www.smashingmagazine.com/2024/08/hist... Lots of new and powerful regex features you might have missed from recent versions of JavaScript!
smashingmagazine.com
Regexes Got Good: The History And Future Of Regular Expressions In JavaScript — Smashing Magazine
Although JavaScript regexes used to be underpowered compared to other modern flavors, numerous improvements in recent years mean that’s no longer true. Steven Levithan evaluates the history and presen...
1186
Steven Levithan @slev.life · 10/11/2024
Thanks @antfu.me! 🙏
010
Steven Levithan @slev.life · 08/11/2024
Introducing Oniguruma-To-ES github.com/slevithan/on... A lightweight JavaScript transpiler for Ruby regexes.
github.com
GitHub - slevithan/oniguruma-to-es: Convert Oniguruma patterns to native JavaScript regexes
Convert Oniguruma patterns to native JavaScript regexes - slevithan/oniguruma-to-es
0110