Regular expressions - zig bindings for libregex

A while back I was doing some string parsing and needed to extract some text. I thought of using a regex to extract that part of the text I’m interested in. That should be easy I thought. But I realized there is no API for regex in the standard library. My immediate next thought was to use the regex library in C. That didn’t work either. I found out translate-c does not support bitfields and C regex implementation uses it. So I thought I’d create a wrapper for the C regex library and that’s what I did. I made the API very convenient to use. Hopefully others find it convenient too.

You can check it out here: GitHub - skota-io/libregex-z: libregex bindings for the zig programming language

Feedback is welcome!

6 Likes

Welcome to Ziggit @skota!

You’ve done something useful here, but that thing isn’t making a regular expression library. It’s providing Zig bindings for libregex, which is a regular expression library.

Putting the string “zig” in the name of a package is discouraged. It should at least mean that the package concerns the Zig language, for instance zig-syntax-highlight might be an ok name for a package which syntax highlights Zig code. But it isn’t appropriate to use it just to indicate “written in Zig”, and this isn’t really written in Zig, it’s a wrapper for a C library: a useful thing, but you’re claiming too much to say “a regex library for the Zig programming language”.

You could call it something like libregex-z, and describe it as “Zig bindings for libregex”, and that would be accurate, and do a good job of conveying to others what the library is and what it’s for.

4 Likes

Thanks for the feedback.

Putting the string “zig” in the name of a package is discouraged.

I see. I think I’ve read about this somewhere before. libregex-z sounds fine, so I’ve updated the repo name and the repo description to it.

Also out of curiosity is there a specific reason it is discouraged? Coming from javascript and go, I’ve seen people make a thing x and then call it x-js or go-x etc. Just wondering why the same thing is discouraged in zig.

1 Like

You might also be interested in libpcre bindings, for something a bit more complete.

4 Likes

6 posts were split to a new topic: Use of the name Zig in package names