2021-09-15

RegEx toolbox

A Regular expression (RegEx, pronounced as Rej-ex) is a technique to find or find/replace a particular pattern in text (or haystack). It's composed of a set of special characters and strings which are used to define complex patterns.

I have decided to consolidate my most frequently used tools in a single Windows installer, below a short description.

Grex GUI

Grex is a regex builder CLI program written in Rust. I have designed a simple graphical interface around it. It's still a work in progress, although it's already usable.

Let's for instance reproduce one of the examples suggested in the README.md file. It starts with a aa and 123, -d and -w options convert any digit and any character to their generic class. This gives a regex that matches every sequence made of three digits and any substring made of one or two characters.

   ^(?:\d\d\d|\w(?:\w)?)$

Windows RegEx tester

From the Grex UI, I can open a customised version of this regex expression tester. I have increased the font size, added a window menu option for loading the haystack from a text file, and it also automatically updates the test regex from the calling Grex UI. When the start and end of the line anchors are removed, it shows that the first match is the first two-word-character sequence encountered in the haystack.