Some Regular Expression Tools

Most of the CriticMarkup processing for the CLI, Sublime Text and BBEdit modules is done with regular expression matching. I’m terrible at regex. My best friend through the whole process was Sublime Text. I could load some example text and pop open the search bar. When in regex mode, the search field highlights the escaped characters and also performs real-time matching on the document ext. Granted, this is some simple regex, but we didn’t start simple, we ended simple.1

There are other great tools for working with regular expressions, but I already do most of my writing in Sublime Text.

This is one of the regular expression I’m using in the CriticMarkup CLI. It’s a beast and to be honest, pretty darn hard for me to read. without a notepad and a pen.

:::Python
(?s)\{\~\~(?P<original>(?:[^\~\>]|(?:\~(?!\>)))+)\~\>(?P<new>(?:[^\~\~]|(?:\~(?!\~\})))+)\~\~\}

My favorite tool for looking at and thinking about how a regex works is Regexper.com. It shows a diagram depicting what’s going on with a regex. I also like the motto: “You thought you only had two problems…”

Unfortunately for me, most of the really good regular expression tools are on Windows. I used them when I really had to but I mostly experimented within CodeRunner by writing some Python code.2

Two great Windows-only tools are RegExBuddy and Regex Coach. Regex Coach is particularly useful because you can watch it step through matching a string, complete with all of the forward and backward movements. It’s kind of mesmerizing. Unfortunately, when I’m on Windows, I’m working. When I’m not working, I’m on a Mac.

The best site for learning about Regular Expressions is probably regular-expressions.info. There’s some good stuff there.


  1. There are also some possible future extensions of CriticMarkup in there. I left them in as a reminder. I’m also terrible at version control and software development. I don’t let that stop me. ↩︎

  2. I own Patterns, but it doesn’t really give me anything I don’t already have with Sublime Text. ↩︎