A Regex Tester in the Browser: How I Use It Every Day
Regular expressions fail silently when they are wrong, and a regex tester catches the failure before it ships. Here is my daily workflow. Regular expressions are part of my daily work. I write them to validate input, to extract fields from text, to clean up logs, to parse user-supplied data. I also write them wrong about a third of the time on the first attempt. The mistakes are usually small: a quantifier in the wrong place, a character class missing a metacharacter, a greedy match that eats too much. Without a regex tester I find these mistakes only when the code runs against bad input. With a tester I find them before I save the file. Here is the workflow I use. Write the Regex Against Real Input, Not Examples The fastest way to write a wrong regex is to test it against made-up examples that match the pattern you already have in mind. It passes, looks correct, and breaks the first time it meets real input. I take a sample of real input first, sometimes fifty lines, sometimes five hundred, and I run the regex against that sample in the tester. More tutorials are on the KitCraft Blog.