A possibly useful text-matching app

Hi All,
Dunno if anyone remembers me :grinning_face: – I used to be a fairly strong presence here 10 or 20 years ago, but I stopped keeping up with things around COVID time, and I’m just getting back into things now. Haiku has remained my favourite OS though; I’ve just been using Linux a bit more. (Just FYI, I’m 90 years old now(!), so I probably set the record of “Oldest Haiku User”!)

Anyway, there’s this app that I mostly wrote 25 years or so ago, but I’ve never really promoted. I use it on a regular basis, though, and I don’t think it’s like anything else around, so maybe it’s worth pushing a bit. I think what decided me was that a few months ago I had a (massive) log file that somehow got corrupted with a batch of nulls, and no text editor seemed to like that much! Maybe it’s just my ignorance, but I couldn’t find any easy way of removing them, until I suddenly realized it was trivial for my program (“matt”)! The command was simply:

matt -v ‘\000’ badfile > goodfile
(see the manual for explanation)

In passing it’s worth noting that, unlike grep, matt is perfectly happy with binary files; it has a switch to make certain it’s dealing with arbitrary 8-bit bytes, but it always accepts any byte, including null. So, if you can figure out the pattern you want (maybe as octal codes), go ahead and scan your binary.

So, if I haven’t lost you already, I’d better detail what the program does! It’s basically a regular expression matcher like ‘grep’, except that it uses Rob Pike’s “Structural Regular Expressions”. These are just like normal Regular Expressions", except they match their target exactly, rather than the line containing the match. This means the match can be a segment of a line or extend over many lines. I realize that languages such as Ruby and Python now have similar regex facilities, but I don’t know any command line app that does.

But wait, there’s more! :slightly_smiling_face: matt also has an optional ‘template’ argument that can edit the match in useful ways. You can select segments of the total match, and add arbitrary text that can depend on whether a specific segment is non-null or not. Together with the more flexible regexs, this makes matt a useful little utility.

I think this is becoming a pretty long post, so I won’t go into more detail here. Please check out my website: https://goodeveca.net/matt for all the details.

BTW, as a command-line app,matt is cross-platform. It compiles from unmodified sources on Linux and Android. (I don’t have either Mac or Windows, but I imagine it’s the same. Let me know if not.) I’ll add direct links to the most important packages here:

Haiku hpkg:
/matt_1.5-x86-gcc2.hpkg

Matt Manual:
MattManual.html

Cross-Platform Sources:
matt_1.5_src.zip

Please check the app out – I’d hate to die and be forgotten! Any feedback much appreciated! No AI was used in the making of this program! Be aware that I won’t be putting this on HaikuDepot; ATM I’ don’t even know how. :neutral_face: I hereby give permission to add any of the BeOS/Haiku apps you find on my website to the HaikuDepot pool. I’d appreciate credit is all.

12 Likes

For some reason I can’t download this with wget?

~/Desktop> wget https://goodeveca.net/matt/matt_1.5_src.zip
--2026-05-27 08:03:37--  https://goodeveca.net/matt/matt_1.5_src.zip
Resolving goodeveca.net... 66.117.151.35
Connecting to goodeveca.net|66.117.151.35|:443... connected.
HTTP request sent, awaiting response... 403 Forbidden
2026-05-27 08:03:38 ERROR 403: Forbidden.

EDIT: seems like the html documentation file isn’t included in the archive. (downloading with WebPositive works)

Sorry, I don’t quite get your edit comment. By “archive” do you mean the website?

I have no idea why my website rejected wget. It’s too late here tonight, but I’ll try tomorrow myself. I, too, have encountered that effect occasionally.

I notice that I did leave out the manual link on the index page. My bad. I’ll fix it tomorrow. The link in my post works though.

I guess you succeeded in the end, anyway.

Hi there @Pete!

Many of us remember you even from ~25+ years ago :slight_smile:. Thanks for your BeOS and Haiku related work, man!

The issue @Begasus had using wget from Pete’s site has been discussed before:

1 Like

The source archive :slight_smile:

tr is the typical utility for that: tr -d '\0' < badfile > goodfile.

grep accepts -a or --text to swallow binary files. I don’t know if it will be perfectly fine with any binary file, but I’ve used it successfully with text files that had portions corrupted or with mixed encoding. It won’t do what matt does, of course, be the files binary or not.