- **Epistemic status:** #evergreen Regular expressions or regex is a search pattern for [[Plain Text]] indicated by a sequence of characters. These patterns can be utilized by string-searching [[Algorithm]]s to find and/or replace string, or for input validation. Regular expressions are supported on the following categories: - Search engines - Search and/or replace strings in word processors or text editors such as [[Vim]] - Text processing utilities such as sed, awk, and lexical analysis - Most programming languages natively or through libraries, including Python, [[JavaScript]], Java, C, C++, Java, etc. - etc Regular expressions are difficult to master, but they are one of those utilities that once you do, it can help you [[Deliver the most value]] by achieving tasks faster and even automating them. Some of the things you can do with it are the following: - You can convert LaTeX math markup into formatted [[Plain Text]] - Automatically fetch files in a directory and update a table of contents with their names - To replace a word used multiple times in multiple files - etc ## Tools You can utilize the following online tools to work with regular expressions: - [REGEX 101](https://regex101.com/) - [REGEXR](https://regexr.com/) ## Cheat sheets The following cheat sheets should be useful in learning more about regular expressions and refreshing your memory: - [MDN Regular Expression Syntax](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_Expressions/Cheatsheet) - [Cheatography Regular Expressions Cheat Sheet by Dave Child](https://cheatography.com/davechild/cheat-sheets/regular-expressions/) - [[Regex JS Cheat Sheet]] --- ## References - Dib, Firas. “Regex101: Build, Test, and Debug Regex.” regex101. Accessed July 19, 2022. <https://regex101.com/>. - RegExr. “RegExr: Learn, Build, & Test RegEx.” Accessed July 19, 2022. <https://regexr.com/>. - “Regular Expression.” In _Wikipedia_, June 27, 2022. <https://en.wikipedia.org/w/index.php?title=Regular_expression&oldid=1095256273>. - “Regular Expression Syntax Cheatsheet - JavaScript | MDN.” Accessed July 19, 2022. <https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_Expressions/Cheatsheet>. - Cheatography. “Regular Expressions Cheat Sheet.” Accessed July 19, 2022. <https://cheatography.com/davechild/cheat-sheets/regular-expressions/>. - Thomas, David, and Andrew Hunt. _The Pragmatic Programmer, 20th Anniversary Edition: Journey to Mastery_. Second edition. Boston: Addison-Wesley, 2019.