update lists
This commit is contained in:
570
readmes/regex.md
570
readmes/regex.md
@@ -1,224 +1,426 @@
|
||||
<!--
|
||||
Title: Awesome Regex
|
||||
Description: A curated list of amazingly awesome regex resources.
|
||||
Author: aloisdg
|
||||
-->
|
||||
<!--lint ignore awesome-heading-->
|
||||
<div align="center">
|
||||
|
||||
# Awesome Regex
|
||||
[](https://github.com/slevithan/awesome-regex)
|
||||
|
||||
[](https://awesome.re)
|
||||
[](https://github.com/aloisdg/awesome-regex/actions)
|
||||
[](https://awesome.re) <sup>Shortcut URL: [`regex.cool`](https://regex.cool/)</sup>
|
||||
</div>
|
||||
|
||||
## Introduction
|
||||
Awesome Regex curates the best regular expression tools, tutorials, libraries, and other resources, covering all major regex flavors.
|
||||
|
||||
A curated collection of awesome Regex libraries, tools, frameworks and software. The goal is to build a categorized community-driven collection of very well-known resources.
|
||||
> [Regular expressions](https://en.wikipedia.org/wiki/Regular_expression) (regex or regexp) are a powerful and concise way to search, parse, and process text. They're built into many programming languages, text editors, IDEs, database engines, word processors, and other tools.
|
||||
|
||||
Inspired by [awesome-dotnet](https://github.com/quozd/awesome-dotnet), [awesome-ruby](https://github.com/markets/awesome-ruby), [awesome-awesomeness](https://github.com/bayandin/awesome-awesomeness) and the whole `awesome-*` trend on GitHub. Thank you [Reddit](http://www.reddit.com/r/regex), [Hacker News](https://news.ycombinator.com/item?id=9581225) and [Stack Overflow](http://stackoverflow.com/tags/regex/info) for the help.
|
||||
Contributions are welcome. Add links through pull requests ([guidelines](CONTRIBUTING.md)).
|
||||
|
||||
Sharing, suggestions and contributions are always welcome! Please take a look at the [contribution guidelines and quality standard](https://github.com/aloisdg/awesome-regex/blob/master/CONTRIBUTING.md) first. Thanks to all contributors, you're awesome and wouldn't be possible without you!
|
||||
<details>
|
||||
<summary>📖 <b>Glossary</b></summary>
|
||||
<br>
|
||||
|
||||
*A brief glossary of regular expression terms as used in this list.*
|
||||
|
||||
- **Regex engine:** Software that interprets and executes regular expressions, either built into a programming language or as a standalone library.
|
||||
- **Regex flavor:** A unique set of regex syntax and behavior. Basic syntax is typically shared across flavors, but more advanced features often vary, sometimes in subtle or incompatible ways. A flavor might be shared across multiple implementations or programming languages.
|
||||
- Ex: The “JavaScript” flavor is defined by the ECMAScript spec; implemented by multiple engines (V8, etc.).
|
||||
- Ex: The “PCRE” flavor is the PCRE2 library, used by numerous programming languages and tools.
|
||||
- Ex: Ruby swapped its regex implementation twice from version 1.8 → 1.9 → 2.0, so each used a distinct flavor. The Ruby 2.0+ flavor is referred to here as either “Ruby” or “Onigmo” (the underlying regex library).
|
||||
- **Non-backtracking engine:** A regex implementation that uses a non-backtracking algorithm and runs in linear time. This rules out worst case performance from superlinear backtracking, but it's slower with some patterns and precludes some useful features like backreferences.
|
||||
</details>
|
||||
|
||||
### Featured resource
|
||||
|
||||
<a href="https://github.com/slevithan/regex">
|
||||
<picture>
|
||||
<source media="(prefers-color-scheme: dark)" srcset="https://cdn.jsdelivr.net/gh/slevithan/regex@5.0.1/media/regex-logo-dark.svg">
|
||||
<img alt="regex logo" height="100" align="right" src="https://cdn.jsdelivr.net/gh/slevithan/regex@5.0.1/media/regex-logo.svg">
|
||||
</picture>
|
||||
</a>
|
||||
|
||||
[Regex+](https://github.com/slevithan/regex) is a lightweight JavaScript library for more readable, high-performance, native JavaScript regexes with powerful features including free spacing, atomic groups, possessive quantifiers, subroutines, subroutine definition groups, and context-aware interpolation.
|
||||
|
||||
## Contents
|
||||
|
||||
- [Documentation](#documentation)
|
||||
- [Prototyping and Testing](#prototyping-and-testing)
|
||||
- [Generators](#generators)
|
||||
- [Security](#security)
|
||||
- [Learning](#learning)
|
||||
- [Libraries](#libraries)
|
||||
- [Collections](#collections)
|
||||
- [Explanation](#explanation)
|
||||
- [Exercises](#exercises)
|
||||
- [Articles](#articles)
|
||||
- [Testers](#testers)
|
||||
- [Syntax-free regex builders](#syntax-free-regex-builders)
|
||||
- [Visualizers](#visualizers)
|
||||
- [Grep-like tools](#grep-like-tools)
|
||||
- [Tutorials](#tutorials)
|
||||
- [Regex engines](#regex-engines)
|
||||
- [Documentation](#documentation)
|
||||
- [Source code](#source-code)
|
||||
- [Flavor differences](#flavor-differences)
|
||||
- [Performance](#performance)
|
||||
- [Collections of patterns](#collections-of-patterns)
|
||||
- [JavaScript regex libraries](#javascript-regex-libraries)
|
||||
- [JavaScript regex evolution](#javascript-regex-evolution)
|
||||
- [Books](#books)
|
||||
- [Benchmarks](#benchmarks)
|
||||
- [Cheat Sheets](#cheat-sheets)
|
||||
- [Articles](#articles)
|
||||
- [Communities](#communities)
|
||||
- [Miscellaneous](#miscellaneous)
|
||||
|
||||
## Documentation
|
||||
## Testers
|
||||
|
||||
- [Regular Expression Language - Quick Reference](https://msdn.microsoft.com/en-us/library/az24scfc(v=vs.110).aspx) - MSDN documentation about Regex.
|
||||
- [Regular Expressions](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_Expressions) - MDN chapter about JavaScript regular expressions.
|
||||
- [Perl Regular Expression Syntax](http://www.boost.org/doc/libs/1_43_0/libs/regex/doc/html/boost_regex/syntax/perl_syntax.html) - Boost documentation.
|
||||
- [Perl 6](https://docs.perl6.org/language/regexes) - Regexes in Perl 6.
|
||||
- [PCRE](http://pcre.org/pcre.txt) - Concatenated PCRE man pages.
|
||||
- [ECMAScript 6](http://2ality.com/2015/07/regexp-es6.html) - New Regexes in ECMAScript 6.
|
||||
- [regex header in C++](http://www.cplusplus.com/reference/regex/) - `<regex>` in C++
|
||||
- [class Pattern in Java](https://docs.oracle.com/javase/7/docs/api/java/util/regex/Pattern.html) - Java 7 docs.
|
||||
- [class Regex in Scala](http://www.scala-lang.org/api/2.12.1/scala/util/matching/Regex.html) - Scala Regex.
|
||||
- [Python re module](https://pymotw.com/3/re/) - Regular Expressions Python module tutorial.
|
||||
- [Regular Expressions in Perl](http://perl-begin.org/topics/regular-expressions/) - Introduction and Reference Links.
|
||||
*For building, testing, and playing with regexes.*
|
||||
|
||||
## Prototyping and Testing
|
||||
- [regex101](https://regex101.com/) - **Best free and best web-based tester**.
|
||||
- Flavors: Java, JavaScript, .NET, PCRE, RE2, Rust, and emulates Python.
|
||||
- Includes regex debugger (PCRE only).
|
||||
- [RegexBuddy](https://www.regexbuddy.com/) (<img src="https://cdn.jsdelivr.net/gh/slevithan/awesome-regex/media/windows.svg" title="Windows" height="13">, $40) - **Best tester**.
|
||||
- Flavors: Emulates hundreds of flavors/versions, with deep knowledge of differences.
|
||||
- Includes regex debugger.
|
||||
- [RegExr](https://regexr.com/) \[[*GitHub*](https://github.com/gskinner/regexr/)] - **Best open source tester**.
|
||||
- Flavors: JavaScript, PCRE.
|
||||
- Languages: 🇺🇸, 🇨🇳 ([fork](https://regexr-cn.com/)).
|
||||
- [RegexLearn](https://regexlearn.com/playground) \[[*GitHub*](https://github.com/aykutkardas/regexlearn.com/blob/develop/src/pages/%5Blang%5D/playground.tsx)] - **Best multilingual tester** (JavaScript).
|
||||
- Languages: 🇺🇸, 🇹🇷, 🇷🇺, 🇪🇸, 🇨🇳, 🇩🇪, 🇺🇦, 🇫🇷, 🇵🇱, 🇰🇷, 🇧🇷, 🇨🇿, 🇬🇪.
|
||||
- [regexplained](https://regexplained.com/) \[[*GitHub*](https://github.com/LeaVerou/regexplained)] - **Best tester for presentations** (JavaScript).
|
||||
|
||||
- [Debuggex](https://www.debuggex.com/) - Online visual Regex tester.
|
||||
- [ExtendsClass](https://extendsclass.com/regex-tester.html) - Online visual Regex tester.
|
||||
- [Nodexr](https://www.nodexr.net) - Online node-based Regex editor.
|
||||
- [Regexr](http://regexr.com/) - Website for interactive Regex prototyping with syntax highlighting (by @gskinner).
|
||||
- [Regex101](https://regex101.com/) - Online Regex tester, debugger with highlighting.
|
||||
- [Rubular](http://rubular.com/) - Ruby-based regular expression editor and tester.
|
||||
- [Rex V](http://www.rexv.org/) - AJAX Regular EXpression eValuator.
|
||||
- [RegViz](http://regviz.org/) - Tool for debugging JavaScript regular expressions in a visual way.
|
||||
- [Regulex](https://jex.im/regulex) - JavaScript Regular Expression Visualizer.
|
||||
- [PyRegex](http://www.pyregex.com/) - Online Regex tester to check validity of Regex in the Python language Regex subset.
|
||||
- [pythex](http://pythex.org/) - Quick way to test your Python regular expressions.
|
||||
- [Regexper](http://regexper.com/) - Regex visualizer for JavaScript using railroad diagrams.
|
||||
- [HiFi Regex Tester](http://www.gethifi.com/tools/regex) - Live JavaScript Regular Expression Tester.
|
||||
- [Regex Hero](http://regexhero.net/tester/) - .NET online Regex tester.
|
||||
- [Regex Storm](http://regexstorm.net/tester) - .NET Regex tester with highlighting and detailed results output.
|
||||
- [RegEx to Strings](https://www.wimpyprogrammer.com/regex-to-strings/) - JavaScript library and online tool to generate strings that a regular expression would match.
|
||||
- [RegexPal](http://www.regexpal.com) - JavaScript + PCRE online tester.
|
||||
- [RegexTester](http://www.regextester.com) - Regular Expression Tester with highlighting for Javascript and PCRE.
|
||||
- [Free Formatter](http://www.freeformatter.com/regex-tester.html) - Free online Regex tester.
|
||||
- [Regex Tester - Golang](https://regex-golang.appspot.com/assets/html/index.html) - A secure regular expression tester. built using Go
|
||||
- [PHP Live Regex](https://www.phpliveregex.com) - PHP specific regular expression tester with live evaluation and code generation for all PHP's regex functions.
|
||||
<details>
|
||||
<summary>✳️ <b>Notable mentions</b></summary>
|
||||
<br>
|
||||
|
||||
## Generators
|
||||
**Command line**
|
||||
|
||||
- [Txt2Re](https://www.txt2re.com/index_php3.html) - Generate Regular expressions based on a string
|
||||
- [Regex Generator++](http://regex.inginf.units.it) - Automatic Generation of Text Extraction Patterns from Examples
|
||||
- [regexgen](https://github.com/devongovett/regexgen) - Generates regular expressions that match a set of strings.
|
||||
- [RegexGenerator](https://github.com/MaLeLabTs/RegexGenerator) - A tool for generating regular expressions for text extraction (by @MaLeLabTs)
|
||||
- [Gamon's numberic range generator](http://gamon.webfactional.com/regexnumericrangegenerator/) - Regex Numeric Range Generator, when you need to match an integer range.
|
||||
- [rgxg](https://rgxg.github.io) - Command line tool to generate Regex
|
||||
- [Strings to RegEx](https://www.wimpyprogrammer.com/strings-to-regex/) - JavaScript library and online tool to generate a regular expression that matches strings.
|
||||
- [Regex Guide](https://regex.guide/playground) - Plain Text to Regex Generator.
|
||||
- [grex](https://github.com/pemistahl/grex) - A command-line tool and library for generating regular expressions from user-provided test cases.
|
||||
- [AutoRegex](https://www.autoregex.xyz/home) - English <-> Regex from an AI.
|
||||
- [pcre2test](https://pcre2project.github.io/pcre2/doc/pcre2test/) - Includes regex debugger. Flavor: PCRE.
|
||||
- [rxrx](https://metacpan.org/dist/Regexp-Debugger/view/bin/rxrx) - Includes regex debugger ([video intro](https://www.youtube.com/watch?v=zcSFIUiMgAs)). Flavor: Perl.
|
||||
|
||||
## Security
|
||||
**By flavor**
|
||||
|
||||
- [SafeRegex](https://github.com/jkutner/saferegex) - A command-line tool for testing regular expressions for [ReDoS](https://owasp.org/www-community/attacks/Regular_expression_Denial_of_Service_-_ReDoS) vulnerabilities.
|
||||
- JavaScript: [RegViz](http://regviz.org/).
|
||||
- .NET: [Regex Storm](http://regexstorm.net/tester) \[[*GitHub*](https://github.com/lonekorean/regex-storm)].
|
||||
- PCRE: [PHP Live Regex](https://www.phpliveregex.com/).
|
||||
- Python: [Pythex](https://pythex.org/).
|
||||
- Ruby: [Rubular](https://rubular.com/).
|
||||
- sed: [GNU sed REPL](https://sed.js.org/).
|
||||
- Swift: [Swift Regex](https://swiftregex.com/) \[[*GitHub*](https://github.com/swiftfiddle/swiftregex)] - Includes regex debugger, DSL builder.
|
||||
|
||||
## Learning
|
||||
**Multiple flavors**
|
||||
|
||||
- [Wikipedia][d1] - Entry on regular expressions.
|
||||
- [Learn Regex The Hard Way][d2] - In-progress book that quickly teaches you regular expressions.
|
||||
- [Regular Expression Matching Can Be Simple And Fast][d3] - Basic concept of how Regex parsing works.
|
||||
- [PDF] [A Tao Of Regular Expressions][d4] - What are Regular Expressions.
|
||||
- [Regular-Expressions.info][d5] - Informative website for learning regular expressions.
|
||||
- [RexEgg][d6] - A regular expressions tutorial that goes deep into advanced features.
|
||||
- [Try Regex][d7] - Try Regex is an interactive regular expressions tutorial.
|
||||
- [Udemy][d8] - A Basic Introduction To Using Regular Expressions In Programming.
|
||||
- [Codecademy][d9] - How to use of regular expression.
|
||||
- [Regex golf][d10] - Regex golf with Peter Norvig.
|
||||
- [Python Regular Expressions][d11] - A good introduction to Python Regular Expressions from Google.
|
||||
- [/Reg(exp){2}lained/: Demystifying Regular Expressions][d12] - Fluent 2012 talk reviewing and visualizing basic and intermediate Regular Expressions.
|
||||
- [Regular Expressions - Everything you should know][d13] - PDF Series.
|
||||
- [The Java Tutorials][d14]
|
||||
- [Regex Syntax Summary][d15]
|
||||
- [How Regexes work][d16]
|
||||
- [Learn Regular Expressions for Beginners][d17]
|
||||
- [Java Regex Tutorial][d18]
|
||||
- [Javascript.info - Regular expressions][d19] - Regular expressions section in The Modern JavaScript Tutorial
|
||||
- [Useful Regexes][d20]
|
||||
- [Teach Yourself Regular Expressions][d21]
|
||||
- [Interactive Regex Tutorial][d22] - Learn Regex step by step, from zero to advanced.
|
||||
- [CyrilEx](https://extendsclass.com/regex-tester.html) \[[*GitHub*](https://github.com/cyrilbois/cyrilex)] - Java, JavaScript, MySQL, PHP, Python, Ruby.
|
||||
- [Patterns](https://krillapps.com/patterns/) (<img src="https://cdn.jsdelivr.net/gh/slevithan/awesome-regex/media/macos.svg" title="macOS" height="13">, $3) - Bash, Emacs, grep, Java, Oniguruma, PCRE, POSIX BRE, POSIX ERE, Ruby, sed.
|
||||
- [RegexPlanet](https://www.regexplanet.com/) \[[*GitHub*](https://github.com/regexplanet)] - Go, Java, JavaScript (Bun, Deno, Node.js), .NET, Perl, PHP, PostgreSQL, Python, Ruby, Rust, Swift, Tcl, XRegExp.
|
||||
</details>
|
||||
|
||||
[d1]: http://en.wikipedia.org/wiki/Regular_expression
|
||||
[d2]: http://regex.learncodethehardway.org/book/
|
||||
[d3]: http://swtch.com/~rsc/regexp/regexp1.html
|
||||
[d4]: http://linuxreviews.org/beginner/tao_of_regular_expressions/tao_of_regular_expressions.en.print.pdf
|
||||
[d5]: http://www.regular-expressions.info/
|
||||
[d6]: http://www.rexegg.com/
|
||||
[d7]: http://tryregex.com/
|
||||
[d8]: https://www.udemy.com/learning-regular-expressions/
|
||||
[d9]: http://www.codecademy.com/courses/javascript-intermediate-en-NJ7Lr/0/1
|
||||
[d10]: https://www.oreilly.com/learning/regex-golf-with-peter-norvig
|
||||
[d11]: https://developers.google.com/edu/python/regular-expressions
|
||||
[d12]: https://www.youtube.com/watch?v=EkluES9Rvak
|
||||
[d13]: http://neverfear.org/blog/view/Regex_tutorial_for_people_who_should_know_Regex__but_do_not___Part_1
|
||||
[d14]: https://docs.oracle.com/javase/tutorial/essential/regex/resources.html
|
||||
[d15]: http://www.greenend.org.uk/rjk/2002/06/regexp.html
|
||||
[d16]: http://perl.plover.com/Regex/
|
||||
[d17]: https://hackernoon.com/javascript-learn-regular-expressions-for-beginners-bb6107015d91
|
||||
[d18]: http://www.vogella.com/tutorials/JavaRegularExpressions/article.html
|
||||
[d19]: https://javascript.info/regular-expressions
|
||||
[d20]: https://atrilsolutions.zendesk.com/hc/en-us/articles/205539861-Useful-regular-expressions
|
||||
[d21]: http://rads.stackoverflow.com/amzn/click/0672325667
|
||||
[d22]: https://regexlearn.com/
|
||||
## Syntax-free regex builders
|
||||
|
||||
## Libraries
|
||||
*Build regexes without writing regex syntax or code.*
|
||||
|
||||
- [Tre](https://laurikari.net/tre/) - Free and portable approximate Regex matching library.
|
||||
- [Go-Restructure](https://github.com/alexflint/go-restructure) - Match regular expressions into struct fields in Go (by @alexflint). [js](https://github.com/benjamingr/js-restructure) [C#](https://gist.github.com/benjamingr/4de21494b3e76088e5f7)
|
||||
- [js-regex](https://github.com/wyantb/js-regex) - Chainable API for construting Regexes.
|
||||
- [VerbalExpressions](https://github.com/VerbalExpressions) - VerbalExpressions is a cross-language library that helps to construct difficult regular expressions.
|
||||
- [Super Expressive](https://github.com/francisrstokes/super-expressive) - Super Expressive is a JavaScript library that allows you to build regular expressions in natural language.
|
||||
- [XRegExp](http://xregexp.com) - JavaScript Regex library.
|
||||
- [RE2](https://github.com/google/re2) - RE2 is a fast, safe, thread-friendly alternative to backtracking regular expression engines like those used in PCRE, Perl, and Python. It is a C++ library.
|
||||
- [Hyperscan](https://github.com/01org/hyperscan) - High-performance multiple Regex matching library.
|
||||
- [ChatGPT](https://chat.openai.com/) (and other LLMs) - Ex: *"create a regex that matches `X` and explain it step by step"*.
|
||||
- [RegexMagic](https://www.regexmagic.com/) (<img src="https://cdn.jsdelivr.net/gh/slevithan/awesome-regex/media/windows.svg" title="Windows" height="13">, $40) - Generate regexes using samples and rules.
|
||||
- Flavors: Emulates hundreds of flavors/versions.
|
||||
|
||||
## Collections
|
||||
<details>
|
||||
<summary>✳️ <b>Notable mentions</b></summary>
|
||||
<br>
|
||||
|
||||
- [RegexLib](http://regexlib.com/) - Regular Expression Library (5000+ indexed expressions).
|
||||
- [Regexhub](https://projects.lukehaas.me/regexhub/) - Useful Regex Patterns.
|
||||
- [RGXP.RU](https://rgxp.ru/) - Regular Expression Patterns (+testing)
|
||||
- [Regex Generator](https://regex-generator.olafneumann.org/) \[[*GitHub*](https://github.com/noxone/regex-generator)] - Generate simple regexes from a sample text.
|
||||
- [Regex.ai](https://regex.ai/) - Mark samples in a text and use AI to generate potential regexes.
|
||||
</details>
|
||||
|
||||
## Explanation
|
||||
## Visualizers
|
||||
|
||||
- [RegexTranslator](https://www.regextranslator.com/) - A web app to decode Regex into plain English. You can edit it and translate back.
|
||||
- [Explain.pl](http://rick.measham.id.au/paste/explain.pl) - Explain Regular Expressions.
|
||||
*Visualize how your regular expressions are structured or operate.*
|
||||
|
||||
## Exercises
|
||||
- [Regex Vis](https://regex-vis.com/) \[[*GitHub*](https://github.com/Bowen7/regex-vis)] - Create railroad diagrams, with visual editor. Flavor: JavaScript.
|
||||
- Languages: 🇺🇸, 🇨🇳.
|
||||
- [Regulex](https://jex.im/regulex/) \[[*GitHub*](https://github.com/CJex/regulex)] - Create railroad diagrams. Flavor: JavaScript.
|
||||
- [Nodexr](https://www.nodexr.net/) \[[*GitHub*](https://github.com/Jcparkyn/nodexr)] - Graphical editor with visual hierarchy. Flavor: .NET.
|
||||
|
||||
- [HackerRank Regex Challenges](https://www.hackerrank.com/domains/regex/re-introduction) - Regex challenges with varying levels of difficulty.
|
||||
- [Redoku](http://padolsey.github.io/redoku/) - Little Regex Sudoku/Crossword thing (by @padolsey).
|
||||
- [Regex Tuesday - Challenges](https://github.com/callumacrae/regex-tuesday) - Challenge list about Regex.
|
||||
- [Regex Crossword](http://regexcrossword.com) - A crossword puzzle game using regular expressions.
|
||||
- [RegexOne](http://regexone.com) - Learn regular expressions with simple, interactive examples.
|
||||
- [Regex Exercises](https://regex.sketchengine.co.uk/) - Regexp exercises.
|
||||
- [Regular Expression Crossword Puzzle](http://gregable.com/2015/12/regular-expression-crossword-puzzle.html) - A crossword puzzle with a neat web interface.
|
||||
<details>
|
||||
<summary>✳️ <b>Notable mentions</b></summary>
|
||||
<br>
|
||||
|
||||
## Articles
|
||||
- [Regex Nodes](https://johannesvollmer.com/regex-nodes/) \[[*GitHub*](https://github.com/johannesvollmer/regex-nodes)] - Graphical editor with visual hierarchy. Flavor: JavaScript.
|
||||
- [Debuggex](https://www.debuggex.com/) - Create railroad diagrams. Flavors: JavaScript, PCRE, Python.
|
||||
- [Regexper](https://regexper.com/) \[[*GitLab*](https://gitlab.com/javallone/regexper-static)] - Create railroad diagrams. Flavor: JavaScript.
|
||||
</details>
|
||||
|
||||
- [5 Techniques to Improve Regex Performance](https://www.loggly.com/blog/five-invaluable-techniques-to-improve-regex-performance/) - Craft your own powerful, yet efficient regex.
|
||||
- [The Bad, the Better, and the Best](https://www.loggly.com/blog/regexes-the-bad-better-best/) - How a few characters can make a difference in performance.
|
||||
- [The Greatest Regex Trick Ever](http://www.rexegg.com/regex-best-trick.html) - So you're doubtful at the mention of a "best Regex trick"?
|
||||
- [Treat regular expressions as code, not magic](http://alexwlchan.net/2016/04/regexes-are-code/) - If you don’t write them carefully, you can end up with an unmaintainable monstrosity.
|
||||
- [Demystifying The Regular Expression That Checks If A Number Is Prime](https://iluxonchik.github.io/regular-expression-check-if-number-is-prime/) - How a regular expression can check if a number is prime.
|
||||
- [Regex Tree: a regular expressions processor](https://medium.com/@DmitrySoshnikov/regexp-tree-a-regular-expressions-parser-with-a-simple-ast-format-bcd4d5580df6)
|
||||
- [The thirty minute regex tutorial](https://www.codeproject.com/Articles/9099/The-Minute-Regex-Tutorial) - Regular Expressions in 30 Minutes.
|
||||
- [Regular Expression Matching Can Be Simple And Fast](https://swtch.com/~rsc/regexp/regexp1.html)
|
||||
- [Regular Expressions in a post ES6 World](https://ponyfoo.com/articles/regular-expressions-post-es6)
|
||||
- [Regular expression (regex) performance: The fundamental guide](https://medium.com/@lennartkoopmann/regular-expression-regex-performance-the-fundamental-guide-3d39e6af33af)
|
||||
- [The New ‘Absent Operator’ in Ruby’s Regular Expressions](https://medium.com/rubyinside/the-new-absent-operator-in-ruby-s-regular-expressions-7c3ef6cd0b99)
|
||||
- [Optimizing regexes in Java](http://www.javaworld.com/article/2077757/core-java/optimizing-regular-expressions-in-java.html)
|
||||
- [Use Regex to Test Password Strength in JavaScript](https://dzone.com/articles/use-regex-test-password)
|
||||
- [Java 101](http://www.javaworld.com/article/3188545/learn-java/java-101-regular-expressions-in-java-part-1.html) - Regular Expressions in Java.
|
||||
- [Most Crazy Regexes](https://stackoverflow.com/questions/800813/what-is-the-most-difficult-challenging-regular-expression-you-have-ever-written) - Stack Overflow
|
||||
- [Regex Humor](http://www.rexegg.com/regex-humor.html) - Regex jokes and cartoons.
|
||||
- [The true power of regular expressions](https://nikic.github.io/2012/06/15/The-true-power-of-regular-expressions.html)
|
||||
- [On code, early neural networks, and once discredited AI pioneers](https://whyisthisinteresting.substack.com/p/the-regular-expression-edition) - A short history of regexes
|
||||
## Grep-like tools
|
||||
|
||||
*Search and replace through files.*
|
||||
|
||||
### Command line
|
||||
|
||||
- [ripgrep](https://github.com/BurntSushi/ripgrep) - Better and faster grep. Recursively searches directories while respecting gitignore rules and skipping hidden/binary files.
|
||||
- Flavors: Rust (default), PCRE.
|
||||
- [nomino](https://github.com/yaa110/nomino) - Rename files uses regexes.
|
||||
- Flavor: Rust.
|
||||
|
||||
➕ **See also:** [Feature comparison of grep-like tools](https://beyondgrep.com/feature-comparison/).
|
||||
|
||||
### GUI
|
||||
|
||||
- [Aba Search and Replace](https://www.abareplace.com/) (<img src="https://cdn.jsdelivr.net/gh/slevithan/awesome-regex/media/windows.svg" title="Windows" height="13">, $30) - Displays matches as you type.
|
||||
- [PowerGREP](https://www.powergrep.com/) (<img src="https://cdn.jsdelivr.net/gh/slevithan/awesome-regex/media/windows.svg" title="Windows" height="13">, $159) - Can search through archives, binary files, PDFs, docs/sheets, emails, etc., via its GUI or the command line.
|
||||
- Flavors: Emulates hundreds of flavors/versions.
|
||||
- [PowerRename](https://github.com/microsoft/PowerToys) (<img src="https://cdn.jsdelivr.net/gh/slevithan/awesome-regex/media/windows.svg" title="Windows" height="13">) - Rename files using regexes.
|
||||
|
||||
## Tutorials
|
||||
|
||||
*Learn how to use regular expressions.*
|
||||
|
||||
### Traditional
|
||||
|
||||
- [Regular-Expressions.info](https://www.regular-expressions.info/) - Covers numerous regex flavors.
|
||||
- [The Modern JavaScript Tutorial: Regular expressions](https://javascript.info/regular-expressions) \[[*GitHub*](https://github.com/javascript-tutorial/en.javascript.info)] - Guide to using regexes in JavaScript.
|
||||
- Languages: 🇺🇸, 🇪🇸, 🇫🇷, 🇮🇹, 🇯🇵, 🇷🇺, 🇺🇦, 🇨🇳 (partial for [others](https://javascript.info/translate)).
|
||||
|
||||
<details>
|
||||
<summary>✳️ <b>Notable mentions</b></summary>
|
||||
<br>
|
||||
|
||||
- [RexEgg](https://rexegg.com/) - Detailed tutorial with advanced topics.
|
||||
- [learnbyexample](https://learnbyexample.github.io/books/) \[[*GitHub*](https://github.com/learnbyexample)] - Ebooks on regexes ([JavaScript](https://learnbyexample.github.io/learn_js_regexp/), [Python](https://learnbyexample.github.io/py_regular_expressions/), [Ruby](https://learnbyexample.github.io/Ruby_Regexp/)) and command line text processing.
|
||||
- [Regular Expressions for Regular Folk](https://refrf.dev/) \[[*GitHub*](https://github.com/shreyasminocha/regex-for-regular-folk)] - Visual, example-based ebook for beginners.
|
||||
</details>
|
||||
|
||||
### With interactive exercises
|
||||
|
||||
- [RegexLearn](https://regexlearn.com/) \[[*GitHub*](https://github.com/aykutkardas/regexlearn.com)] - Interactive tutorial and practice problems.
|
||||
- Languages: 🇺🇸, 🇹🇷, 🇷🇺, 🇪🇸, 🇨🇳, 🇩🇪, 🇺🇦, 🇫🇷, 🇵🇱, 🇰🇷, 🇧🇷, 🇨🇿, 🇬🇪.
|
||||
- [RegexOne](https://regexone.com/) - Interactive tutorial and practice problems.
|
||||
|
||||
### Videos
|
||||
|
||||
- [*Demystifying Regular Expressions*](https://www.youtube.com/watch?v=M7vDtxaD7ZU) - Great presentation for beginners, by Lea Verou at HolyJS 2017 (1hr 12m).
|
||||
- [*Learn Regular Expressions In 20 Minutes*](https://www.youtube.com/watch?v=rhzKDrUiJVk) - Live syntax walkthrough in a regex tester, by Kyle Cook.
|
||||
- Many options for video courses are available on [Udemy](https://www.udemy.com/topic/regular-expressions/) ($).
|
||||
|
||||
## Regex engines
|
||||
|
||||
*Major regex implementations, built into programming languages or as standalone libraries.*
|
||||
|
||||
### Documentation
|
||||
|
||||
*Official regex references and guides.*
|
||||
|
||||
#### Regex flavors
|
||||
|
||||
- Boost.Regex: [Manual](https://boost.org/libs/regex).
|
||||
- C++: [Regular expressions library](https://en.cppreference.com/w/cpp/regex).
|
||||
- Hyperscan: [Introduction](https://www.hyperscan.io/).
|
||||
- ICU: [Regular Expressions](https://unicode-org.github.io/icu/userguide/strings/regexp.html).
|
||||
- Java: [Pattern](https://docs.oracle.com/en/java/javase/22/docs/api/java.base/java/util/regex/Pattern.html), [API](https://docs.oracle.com/en/java/javase/22/docs/api/java.base/java/util/regex/package-summary.html).
|
||||
- JavaScript: [RegExp](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp), [Reference](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Regular_expressions), [Guide](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_expressions), [Cheatsheet](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_expressions/Cheatsheet).
|
||||
- .NET: [Overview](https://learn.microsoft.com/en-us/dotnet/standard/base-types/regular-expressions), [Language](https://learn.microsoft.com/en-us/dotnet/standard/base-types/regular-expression-language-quick-reference), [API](https://learn.microsoft.com/en-us/dotnet/api/system.text.regularexpressions).
|
||||
- Onigmo: [RE](https://github.com/k-takata/Onigmo/blob/master/doc/RE).
|
||||
- Oniguruma: [RE](https://github.com/kkos/oniguruma/blob/master/doc/RE).
|
||||
- PCRE2: [Pattern](https://pcre2project.github.io/pcre2/doc/pcre2pattern/), [API](https://pcre2project.github.io/pcre2/doc/).
|
||||
- Perl: [Syntax](https://perldoc.perl.org/perlre), [Tutorial](https://perldoc.perl.org/perlretut), [Quick Start](https://perldoc.perl.org/perlrequick).
|
||||
- Python: [re](https://docs.python.org/library/re.html).
|
||||
- RE2: [Syntax](https://github.com/google/re2/wiki/Syntax).
|
||||
- Rust: [regex](https://docs.rs/regex) - See also: [regex-lite](https://docs.rs/regex-lite).
|
||||
- Swift: [Regex](https://developer.apple.com/documentation/swift/regex/) - See also: [RegexBuilder](https://developer.apple.com/documentation/regexbuilder), [NSRegularExpression](https://developer.apple.com/documentation/foundation/nsregularexpression).
|
||||
|
||||
ℹ️ Raku (formerly Perl 6) reimagines regexes. See: [Grammars](https://docs.raku.org/language/grammars) ([tutorial](https://docs.raku.org/language/grammar_tutorial)), [Regexes](https://docs.raku.org/language/regexes) ([best practices](https://docs.raku.org/language/regexes-best-practices)).
|
||||
|
||||
#### Without own flavor
|
||||
|
||||
- Go: [regexp](https://pkg.go.dev/regexp) - Flavor: RE2.
|
||||
- MySQL: [Regular Expressions](https://dev.mysql.com/doc/refman/en/regexp.html) - Flavor: ICU.
|
||||
- PHP: [Regular Expressions](https://www.php.net/manual/en/book.pcre.php) - Flavor: PCRE.
|
||||
- Ruby: [Regexp](https://docs.ruby-lang.org/en/master/Regexp.html) - Flavor: Onigmo.
|
||||
|
||||
### Source code
|
||||
|
||||
*Read or contribute to the code behind major regex implementations.*
|
||||
|
||||
- [Boost.Regex](https://github.com/boostorg/regex) - Popular C++ regex library.
|
||||
- [Hyperscan](https://github.com/intel/hyperscan) - Intel's high-performance library, used for [DPI](https://en.wikipedia.org/wiki/Deep_packet_inspection).
|
||||
- [ICU](https://github.com/unicode-org/icu/blob/main/icu4c/source/i18n/regexcmp.cpp) - Unicode org's package with full Unicode support.
|
||||
- [Java: java.util.regex](https://github.com/openjdk/jdk/tree/master/src/java.base/share/classes/java/util/regex) - JDK standard regexes.
|
||||
- JavaScript:
|
||||
- [JavaScriptCore: RegExp](https://github.com/WebKit/WebKit/blob/main/Source/JavaScriptCore/runtime/RegExp.cpp) - Regex engine used by Safari.
|
||||
- [V8: Irregexp](https://github.com/v8/v8/tree/main/src/regexp) - Regex engine used by Chrome, Edge, [Firefox](https://hacks.mozilla.org/2020/06/a-new-regexp-engine-in-spidermonkey/), etc.
|
||||
- [.NET: System.Text.RegularExpressions](https://github.com/dotnet/runtime/tree/main/src/libraries/System.Text.RegularExpressions) - Shared by all .NET languages (C#, VB, etc.).
|
||||
- [Onigmo](https://github.com/k-takata/Onigmo) - Forked from Oniguruma. Used by Ruby 2.0+.
|
||||
- [Oniguruma](https://github.com/kkos/oniguruma) - Popular C regex library used by Ruby 1.9, TextMate grammars, etc.
|
||||
- [PCRE2](https://github.com/PCRE2Project/pcre2) - Popular C regex library used by PHP, R, etc.
|
||||
- [Perl](https://github.com/Perl/perl5/blob/blead/regexp.h) - See [perlreguts](https://perldoc.perl.org/perlreguts).
|
||||
- [Python: re](https://github.com/python/cpython/tree/main/Lib/re) and [regex](https://github.com/mrabarnett/mrab-regex) - Standard and extended regex libraries.
|
||||
- [RE2](https://github.com/google/re2) - Popular C++ regex library used by Go, etc. Non-backtracking engine.
|
||||
- [Rust: regex](https://github.com/rust-lang/regex) - Non-backtracking engine.
|
||||
|
||||
### Flavor differences
|
||||
|
||||
*Syntax and behavior differences between regex flavors.*
|
||||
|
||||
- Ron Buckton: [Regular Expression Feature Comparisons](https://rbuckton.github.io/regexp-features/) \[[*GitHub*](https://github.com/rbuckton/regexp-features)].
|
||||
- Regular-Expressions.info: [Tools & Languages](https://www.regular-expressions.info/tools.html).
|
||||
- Steven Levithan: [Named capture](https://xregexp.com/syntax/named_capture_comparison/), [Lookbehind](https://stevenlevithan.com/regex/tests/lookbehind.html).
|
||||
- Wikipedia: [Comparison of regular expression engines](https://en.wikipedia.org/wiki/Comparison_of_regular_expression_engines).
|
||||
|
||||
## Performance
|
||||
|
||||
*Pattern and engine performance, benchmarks, and [ReDoS](https://en.wikipedia.org/wiki/ReDoS) prevention.*
|
||||
|
||||
### Crafting efficient regexes
|
||||
|
||||
- [Runaway Regular Expressions: Catastrophic Backtracking](https://www.regular-expressions.info/catastrophic.html) - Exploration and solutions for superlinear backtracking.
|
||||
- [Book: High Performance JavaScript](https://www.amazon.com/dp/059680279X/?tag=slev-20) (2010) - *Chapter 5: Strings and Regular Expressions*.
|
||||
- [Book: Mastering Regular Expressions, 3rd Edition](https://www.amazon.com/Mastering-Regular-Expressions-Jeffrey-Friedl/dp/0596528124/?tag=slev-20) (2006) - *Chapter 6: Crafting an Efficient Expression*.
|
||||
- [Performance of Greedy vs. Lazy Regex Quantifiers](https://blog.stevenlevithan.com/archives/greedy-lazy-performance) - Illustrates the mechanics of backtracking.
|
||||
|
||||
ℹ️ With backtracking engines, how you craft a regex can affect how fast it finds matches or reports failures.
|
||||
|
||||
<details>
|
||||
<summary>✳️ <b>Notable mentions</b></summary>
|
||||
<br>
|
||||
|
||||
- [Performance of Regular Expressions](https://medium.com/textmaster-engineering/performance-of-regular-expressions-81371f569698) - On backtracking performance, with detailed examples.
|
||||
</details>
|
||||
|
||||
### Regex engine optimization
|
||||
|
||||
- [Regular Expression Matching Can Be Simple And Fast](https://swtch.com/~rsc/regexp/regexp1.html) - On non-backtracking engines. A [follow up](https://swtch.com/~rsc/regexp/regexp3.html) includes comparisons of RE2 and PCRE performance.
|
||||
- [Regular Expression Improvements in .NET 7](https://devblogs.microsoft.com/dotnet/regular-expression-improvements-in-dotnet-7/) and [.NET 5](https://devblogs.microsoft.com/dotnet/regex-performance-improvements-in-net-5/) - Includes detailed explanations of performance optimizations.
|
||||
- [ripgrep is faster than {grep, …}](https://blog.burntsushi.net/ripgrep/) - Includes details about what makes ripgrep and Rust's `regex` fast.
|
||||
|
||||
### Benchmarking
|
||||
|
||||
- Cross-engine benchmarking libraries: [rebar](https://github.com/BurntSushi/rebar), [regex-benchmark](https://github.com/mariomka/regex-benchmark).
|
||||
- [Boost.Regex: Performance](https://www.boost.org/doc/libs/release/libs/regex/doc/html/boost_regex/background/performance.html) - Compares Boost, C++ `std::regex`, and others.
|
||||
|
||||
### ReDoS checkers
|
||||
|
||||
- [regex.rip](https://regex.rip/) - Test a regex for ReDoS vulnerability.
|
||||
- [recheck](https://github.com/makenowjust-labs/recheck) \[[*home*](https://makenowjust-labs.github.io/recheck/)] - JavaScript and Scala library for detecting ReDoS vulnerability. Can be used as an ESLint plugin.
|
||||
- [vuln-regex-detector](https://github.com/davisjam/vuln-regex-detector) - Perl library for detecting ReDoS vulnerability.
|
||||
|
||||
⚠️ These tools have limitations on supported syntax.
|
||||
|
||||
## Collections of patterns
|
||||
|
||||
*Prewritten regexes for specific tasks.*
|
||||
|
||||
- [Book: Regular Expressions Cookbook, 2nd Edition](https://www.amazon.com/Regular-Expressions-Cookbook-Solutions-Programming/dp/1449319432/?tag=slev-20) (2012) - High-quality solutions with detailed explanations.
|
||||
- Flavors: Java, JavaScript, .NET, PCRE, Perl, Python, Ruby, XRegExp.
|
||||
- [Regex DB](https://rgxdb.com/) - Solutions include basic descriptions and examples of matching and non-matching text.
|
||||
|
||||
<details>
|
||||
<summary>⚠️ <b>Word of warning</b></summary>
|
||||
<br>
|
||||
|
||||
Many regexes found online are low quality. It's risky to use regexes you don't fully understand in code, since they might have false positives/negatives, be vulnerable to performance problems with certain target strings, or assume a different regex flavor.
|
||||
</details>
|
||||
|
||||
## JavaScript regex libraries
|
||||
|
||||
*Open source JavaScript libraries for advanced regex use and processing.*
|
||||
|
||||
### Alternative regex builders and engines
|
||||
|
||||
- [Regex+](https://github.com/slevithan/regex) - A template tag for extended, readable, high-performance JavaScript regexes.
|
||||
- [Oniguruma-To-ES](https://github.com/slevithan/oniguruma-to-es) - Convert Oniguruma patterns to native JavaScript regexes.
|
||||
- [XRegExp](https://github.com/slevithan/xregexp) \[[*home*](https://xregexp.com/)] - Extended regex syntax, flags, and utils; useful for backcompat.
|
||||
- [incr-regex-package](https://github.com/nurulc/incr-regex-package) - Partial/incremental matching, used by [react-rxinput](https://github.com/nurulc/react-rxinput) for input validation with a regex mask.
|
||||
- Use other engines via WASM bindings: [node-re2](https://github.com/uhop/node-re2) (RE2), [rregex](https://github.com/2fd/rregex) (Rust's `regex`), [vscode-oniguruma](https://github.com/microsoft/vscode-oniguruma) (Oniguruma).
|
||||
|
||||
### Abstracted regex syntax
|
||||
|
||||
- [Rexx](https://github.com/yyytcool/rexx) - A template tag that uses structured syntax with variables and comments.
|
||||
- [Melody](https://github.com/yoav-lavi/melody) \[[*docs*](https://yoav-lavi.github.io/melody/book/)] - A language that compiles to regexes.
|
||||
- Compose with functions: [compose-regexp.js](https://github.com/compose-regexp/compose-regexp.js), [VerbalExpressions](https://github.com/VerbalExpressions/JSVerbalExpressions) (implementations for [many languages](https://verbalexpressions.github.io/)), [magic-regexp](https://github.com/unjs/magic-regexp) \[[*home*](https://regexp.dev/)], [Super Expressive](https://github.com/francisrstokes/super-expressive) \[[*playground*](https://nartc.github.io/ng-super-expressive/)].
|
||||
|
||||
### Regex processors
|
||||
|
||||
- AST builders: [regexpp](https://github.com/eslint-community/regexpp) (used by ESLint), [regexp-tree](https://github.com/DmitrySoshnikov/regexp-tree) (includes optimizer, etc.), [regjsparser](https://github.com/jviereck/regjsparser)/[regjsgen](https://github.com/bnjmnt4n/regjsgen).
|
||||
- AST explorers: [AST Explorer: RegExp](https://astexplorer.net/#/gist/56d33dc28d07c7f57bdf5ca0f4061320/c6b67a829334151af01ba55960c653e4462df437), [JS RegExp AST Viewer](https://leaysgur.github.io/js-regexp-ast-viewer/).
|
||||
- [regexp-ast-analysis](https://github.com/RunDevelopment/regexp-ast-analysis) \[[*docs*](https://rundevelopment.github.io/regexp-ast-analysis/docs/latest/)] - Analyze AST nodes produced by regexpp.
|
||||
- Highlight regex syntax: [Regex Colorizer](https://github.com/slevithan/regex-colorizer) \[[*home*](https://slevithan.github.io/regex-colorizer/demo/)], [CodeMirror PCRE mode](https://github.com/xavierog/codemirror-mode-pcre).
|
||||
- Find regex mistakes and improvements: [eslint-plugin-regexp](https://github.com/ota-meshi/eslint-plugin-regexp) \[[*home*](https://ota-meshi.github.io/eslint-plugin-regexp/)], [eslint-plugin-optimize-regex](https://github.com/BrainMaestro/eslint-plugin-optimize-regex).
|
||||
- Generate strings that match a given regex: [randexp.js](https://github.com/fent/randexp.js), [regex-to-strings](https://github.com/wimpyprogrammer/regex-to-strings).
|
||||
- Generate a regex from given strings: [regexgen](https://github.com/devongovett/regexgen).
|
||||
|
||||
## JavaScript regex evolution
|
||||
|
||||
*The history of improvements to regular expressions in the JavaScript [standard](https://tc39.es/ecma262/multipage/). Starting with ES2018, includes links to the TC39 proposals where features were developed and discussed.*
|
||||
|
||||
- ES3 (1999) introduced regular expressions.
|
||||
- ES5 (2009) fixed unintuitive behavior by creating a new object every time regex literals are evaluated \[[*explainer*](https://whereswalden.com/2010/01/15/more-es5-incompatible-changes-regular-expressions-now-evaluate-to-a-new-object-not-the-same-object-each-time-theyre-encountered/)], and allowed regex literals to use unescaped forward slashes within character classes (`/[/]/`).
|
||||
- ES6/ES2015 added: \[[*explainer*](https://2ality.com/2015/07/regexp-es6.html)]
|
||||
- Flag `y` (`sticky`), which anchors matches to `lastIndex`.
|
||||
- Flag `u` (`unicode`) \[[*explainer*](https://mathiasbynens.be/notes/es6-unicode-regex)] \[[*2016 spec fix*](https://github.com/tc39/ecma262/pull/525)], which adds Unicode code point escapes via `\u{…}`, strict errors (for unreserved escapes, octal escapes, quantified lookahead, and unescaped special characters in some contexts), Unicode case-folding for flag `i`, and code point matching (with impact on quantifiers, character classes, ranges, and built-in sets).
|
||||
- Getter `RegExp.prototype.flags`, the ability to copy a regex using `RegExp` (optionally with new flags), and support for subclassing `RegExp` (along with `RegExp.prototype[Symbol.match`/`replace`/`search`/`split]` and `RegExp[Symbol.species]`).
|
||||
- ES2018 added [flag `s`](https://github.com/tc39/proposal-regexp-dotall-flag) (`dotAll`), [lookbehind](https://github.com/tc39/proposal-regexp-lookbehind), [named capture](https://github.com/tc39/proposal-regexp-named-groups), and [Unicode properties](https://github.com/tc39/proposal-regexp-unicode-property-escapes) (via `\p{…}` and `\P{…}` which require flag `u`; see [list](https://github.com/mathiasbynens/regexpu-core/blob/main/property-escapes.md)).
|
||||
- ES2020 added string method [`matchAll`](https://github.com/tc39/proposal-string-matchall) (which returns an iterator), plus `RegExp.prototype[Symbol.matchAll]`.
|
||||
- ES2022 added [flag `d`](https://github.com/tc39/proposal-regexp-match-indices) (`hasIndices`), which provides start/end indices for matched substrings.
|
||||
- ES2024 added [flag `v`](https://github.com/tc39/proposal-regexp-v-flag) (`unicodeSets`) \[[*explainer*](https://v8.dev/features/regexp-v-flag)] as an upgrade to flag `u`, which adds a set of multicharacter "properties of strings" to `\p{…}`, multicharacter elements within character classes via `\p{…}` and `\q{…|…}`, nested character classes, set operators `[…--…]` and `[…&&…]`, and different escaping rules within character classes. It also fixes case-insensitive matching for `\p` and `\P` within negated `[^…]`.
|
||||
|
||||
> Each edition from ES2019 to ES2023 added additional Unicode properties that can be used via `\p{…}` and `\P{…}` (see [lists](https://github.com/eslint-community/regexpp/blob/main/src/unicode/properties.ts)). ES2021 added string method [`replaceAll`](https://github.com/tc39/proposal-string-replaceall), although, when given a regex, the only difference from ES3's `replace` is that it throws if not using flag `g`.
|
||||
<details>
|
||||
<summary>➕ <b>See also</b></summary>
|
||||
<br>
|
||||
|
||||
- [*Regexes Got Good: The History And Future Of Regular Expressions In JavaScript*](https://www.smashingmagazine.com/2024/08/history-future-regular-expressions-javascript/)
|
||||
- Backcompat libraries: [regexpu](https://github.com/mathiasbynens/regexpu), [regenerate](https://github.com/mathiasbynens/regenerate) ([Unicode property sets](https://github.com/mathiasbynens/regenerate-unicode-properties)).
|
||||
- Chrome's `l` (`linear`) regex flag, behind a V8 flag \[[*explainer*](https://v8.dev/blog/non-backtracking-regexp)] \[[*how to run*](https://www.chromium.org/developers/how-tos/run-chromium-with-flags/)].
|
||||
- [Can I use](https://caniuse.com/) - Up-to-date browser support tables for individual features.
|
||||
</details>
|
||||
|
||||
<details>
|
||||
<summary>🔮 <b>Future: Active proposals</b></summary>
|
||||
<br>
|
||||
|
||||
- [Duplicate named capturing groups](https://github.com/tc39/proposal-duplicate-named-capturing-groups) (2022) - Ex: `(?<a>…)|(?<a>…)`.
|
||||
- [Extended mode and comments](https://github.com/tc39/proposal-regexp-x-mode) (2021) - Flag `x` (`extended`) with insignificant whitespace and line comments (`#…`), plus inline comments via `(?#…)`.
|
||||
- [Pattern modifiers](https://github.com/tc39/proposal-regexp-modifiers) (2021) - Ex: `(?ims:…)`, `(?-ims:…)`, `(?i-ms:…)`.
|
||||
- [Atomic operators](https://github.com/tc39/proposal-regexp-atomic-operators) (2021) - Atomic groups via `(?>…)` and possessive quantifiers (ex: `*+`, `++`).
|
||||
- [Buffer boundaries](https://github.com/tc39/proposal-regexp-buffer-boundaries) (2021) - Anchors `\A` and `\z`, not affected by flag `m`.
|
||||
- [\R escape](https://github.com/tc39/proposal-regexp-r-escape) (2021) - Outside character classes, `\R` matches any line terminator.
|
||||
- [Restrict subclassing support in built-ins](https://github.com/tc39/proposal-rm-builtin-subclassing) (2020) - Scaled back `RegExp` subclassing.
|
||||
- [RegExp escaping](https://github.com/tc39/proposal-regex-escaping) (2015) - `RegExp.escape`.
|
||||
- [Legacy RegExp features](https://github.com/tc39/proposal-regexp-legacy-features) (2015) - Standardization of legacy features.
|
||||
</details>
|
||||
|
||||
## Books
|
||||
|
||||
- [Patterns, Automata, and Regular Expressions](http://infolab.stanford.edu/~ullman/focs/ch10.pdf) - Al Aho and Jeff Ullman (1992) (*chapter 10 of [Foundations of Computer Science](http://infolab.stanford.edu/~ullman/focs.html)*)
|
||||
- [Beginning Regular Expressions](http://shop.oreilly.com/product/9780764574894.do) - Andrew Watt (2005)
|
||||
- [Mastering Regular Expressions](http://shop.oreilly.com/product/9780596528126.do) - Jeffrey E.F. Friedl (2006)
|
||||
- [Regular Expression Pocket Reference](http://shop.oreilly.com/product/9780596514273.do) - Tony Stubblebine (2007)
|
||||
- [Introducing Regular Expressions](http://shop.oreilly.com/product/0636920012337.do) - Michael Fitzgerald (2012)
|
||||
- [Regular Expressions Cookbook](http://shop.oreilly.com/product/0636920023630.do) - Jan Goyvaerts & Steven Levithan (2012)
|
||||
- [Mastering Python Regular Expressions](http://shop.oreilly.com/product/9781783283156.do) - Felix Lopez & Victor Romero (2014)
|
||||
- [JavaScript Regular Expressions](http://shop.oreilly.com/product/9781783282258.do) - Loiane Groner & Gabriel Manricks (2015)
|
||||
- [Regex - the complete tutorial](https://www.princeton.edu/~mlovett/reference/Regular-Expressions.pdf)
|
||||
- [Python re(gex)?](https://github.com/learnbyexample/py_regular_expressions) - Sundeep Agarwal (2020)
|
||||
*A curated list of regex books.*
|
||||
|
||||
## Benchmarks
|
||||
- [*Regular Expressions Cookbook, 2nd Edition*](https://www.amazon.com/dp/1449319432/?tag=slev-20) (2012) by Jan Goyvaerts and Steven Levithan - Regex tutorial with code samples for eight programming languages, 100+ regex recipes for practical problems, and a deep focus on cross-flavor differences.
|
||||
- Flavors: Java, JavaScript, .NET, PCRE, Perl, Python, Ruby, XRegExp.
|
||||
- [*Mastering Regular Expressions, 3rd Edition*](https://www.amazon.com/dp/0596528124/?tag=slev-20) (2006) by Jeffrey Friedl - A computer science classic, best for people who already know the basics. Includes good coverage of crafting efficient regexes.
|
||||
- Flavors: Dedicated chapters on Java, .NET, Perl, and PHP (PCRE), with more limited coverage of Python, Tcl, command line tools, etc.
|
||||
- [*Introducing Regular Expressions*](https://www.amazon.com/dp/1449392687/?tag=slev-20) (2012) by Michael Fitzgerald - An intro for programmers new to regular expressions that sticks to the basics.
|
||||
|
||||
- [Benchmark of Regex Libraries](http://lh3lh3.users.sourceforge.net/reb.shtml)
|
||||
- [Java regular expression library benchmarks – 2015](https://www.javaadvent.com/2015/12/java-regular-expression-library-benchmarks-2015.html)
|
||||
- [Languages Regex Benchmark](https://github.com/mariomka/regex-benchmark) - It's just a simple Regex benchmark of different programming languages.
|
||||
- [Performance comparison of regular expression engines](http://sljit.sourceforge.net/regex_perf.html)
|
||||
- [Regex Performance](https://github.com/rust-leipzig/regex-performance) - Performance comparison of regular expression engines.
|
||||
## Articles
|
||||
|
||||
## Cheat Sheets
|
||||
*A curated list of regex articles.*
|
||||
|
||||
- [Regular Expressions Cheat Sheet](https://www.cheatography.com/davechild/cheat-sheets/regular-expressions/)
|
||||
- [Regex Cheat Sheet](http://www.rexegg.com/regex-quickstart.html)
|
||||
- [MIT Cheat Sheet](http://web.mit.edu/hackl/www/lab/turkshop/slides/regex-cheatsheet.pdf)
|
||||
- [Java Cheat Sheet](https://zeroturnaround.com/rebellabs/java-regular-expressions-cheat-sheet/)
|
||||
- [JavaScript Cheat Sheet](https://www.debuggex.com/cheatsheet/regex/javascript)
|
||||
- [RegexLearn Cheat Sheet](https://regexlearn.com/cheatsheet)
|
||||
- [*The World's Shortest Regex Compiler?*](https://jasonhpriestley.com/regex) and a [follow up](https://jasonhpriestley.com/regex-dfa) on optimization - Introduction to writing a non-backtracking regex engine (in JavaScript).
|
||||
- [*Regex Legends: The People Behind the Magic*](https://blog.stevenlevithan.com/archives/regex-legends) - Influential people behind the technology.
|
||||
- [*Fun With .NET Regex Balancing Groups*](https://blog.stevenlevithan.com/archives/balancing-groups) - Advanced usage of a .NET-only regex feature.
|
||||
|
||||
# Other awesome lists
|
||||
## Communities
|
||||
|
||||
Other amazingly awesome lists can be found at the [official awesome list](https://github.com/sindresorhus/awesome) and [here](https://github.com/jnv/lists).
|
||||
*Discuss, assist, and get help with regular expressions.*
|
||||
|
||||
- [Reddit: r/regex](https://www.reddit.com/r/regex/)
|
||||
- [Stack Overflow: [regex]](https://stackoverflow.com/questions/tagged/regex?tab=Votes)
|
||||
|
||||
## Miscellaneous
|
||||
|
||||
*Other interesting, fun, and useful stuff.*
|
||||
|
||||
- Quiz: [regex101 Regex Quiz](https://regex101.com/quiz) - Requires sign-in.
|
||||
- Games: [Regex Crossword](https://regexcrossword.com/), [regexle](https://regexle.com/), [The Typing of the RegEX](https://thetypingoftheregex.com/), [Regex Machina](https://codepip.com/games/regex-machina/) ($).
|
||||
- Comics: [xkcd](https://xkcd.com/208/), [Garabato Kid](https://twitter.com/garabatokid/status/1147063121678389253).
|
||||
|
||||
## About
|
||||
|
||||
Awesome Regex was created by [Steven Levithan](https://github.com/slevithan) and [contributors](https://github.com/slevithan/awesome-regex/graphs/contributors).
|
||||
|
||||
### Sponsors and backers
|
||||
|
||||
[<img src="https://github.com/brc-dd.png" width="40" height="40">](https://github.com/brc-dd)
|
||||
[<img src="https://github.com/roboflow.png" width="40" height="40">](https://github.com/roboflow)
|
||||
|
||||
### Past sponsors
|
||||
|
||||
[<img src="https://github.com/antfu.png" width="40" height="40">](https://github.com/antfu)
|
||||
|
||||
If you want to support this project, I'd love your help by contributing improvements, sharing it with others, or [sponsoring](https://github.com/sponsors/slevithan) ongoing development.
|
||||
|
||||
© 2024–present. CC BY 4.0.
|
||||
|
||||
[regex.md Github](https://github.com/slevithan/awesome-regex
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user