Tag Archives: regex

regexProgram: Add to your education

I don’t want this program to be bracketed as a “game” really, but it will probably look like one after a weekend of games. This is regexProgram, and I see this more as a practice or an exercise than a game, per se.


If you’re like me, and you only need or use regular expressions about two or three times a month, it’s not a skill that is particularly well developed. I know enough to search the vast wealth of the Internet to get something done, but not enough to muddle through things on my own.

regexProgram is a series of drills to think your way through, with each exercise becoming more and more complex. The first two or so were accessible to me, but beyond that, and I had to start looking for help elsewhere.

So in that sense, I can tell you that this isn’t a tool for solving regular expressions, like txt2regex was. And it’s not really a game, unless you find this sort of thing amusing and you’re willing to keep score on your own. πŸ˜•

But it will challenge you to think of specific cases, along with specific exclusions, and put them into expressions. It’s good practice.

As far as I can tell (because of course, after the second exercise I was completely over my head), regexProgram runs through the same 10 exercises each time, in a specific order. The README file describes a way to add your own exercises, which is a nice touch.

My only suggestion would be to add line numbers to the exercise array. The “hint” line guides you as you build your expression, but uses line numbers to draw your attention to specific cases. But there are no line numbers shown, which means you have to mentally count down line by line to see what the hint is … hinting at. πŸ™„

Beyond that, regexProgram is quite straightforward. On-screen prompts and color highlighting make it very quick to learn and read. The version you see above was built with Arch, the only dependency being ncurses (of course) and boost. Debian users can probably build it with the same libraries installed.

And while I wouldn’t call it a game, it’s definitely one worth keeping around, even just for educational purposes. I’m willing to give it a gold star for doing most everything right, incorporating a splash of color, and adding to my education. ⭐ Cheers! πŸ˜‰

txt2regex: A regex newbie’s best friend

Not just newbies either: It’s probably easier to build and deconstruct complex regex patterns with txt2regex than just to muddle through.

2014-06-05-6m47421-txt2regex-01 2014-06-05-6m47421-txt2regex-02

Unless you’re some kind of regex wizard. Some kind of regex grand pooh-bah. Unless you decide how you’ll get to the grocery store with regex snippets. In that case, you probably don’t need to be visiting this site. πŸ‘Ώ

txt2regex is probably one of the coolest little terminal toys I’ve seen in a while. txt2regex will step through your logic and build up a pattern piece by piece, offering the appropriate options at the right locations.

txt2regex also tailors its results to any of about 12 or more different programs or languages, meaning you can get results for vim and python, and not have to think about trying to spot differences between them.

If you look at the second screenshot up there, you can see that not only does txt2regex spit out a natural speech rendition of your pattern, but also provides for a history tool, so you can come back and edit your attempt, if something didn’t work how you wanted.

That means you don’t have to retype all your failed attempts, just to get back to your workable state. Nifty.

txt2regex is not a new program; the home page suggests it has been around for at least 10 years. I suspect it is very much under the radar though, quite possibly because it doesn’t really come into use until a person reaches a certain degree of computer proficiency. I don’t think txt2regex would have thrilled me back when I was just a Linux newb. (Who am I kidding? I still am a newb.)

But now, it’s a very clever, very useful tool, and I plan on keeping it around. You know how I am about programs with color. … πŸ™‚