Libreg
Regular expressions library implemented as non-deterministic finite-state automata.
Install / Use
/learn @txus/LibregREADME
libreg 
Simple regular expressions library implemented as non-deterministic finite-state automata. No fancy features, very basic.
Design inspired by Understanding Computation, an amazing book by Tom Stuart.
Usage
#include <reg/reg.h>
unsigned int matched = 0;
Reg *regex = Reg_compile("ab|c");
matched = Reg_match(regex, "ac"); // matched! 1
matched = Reg_match(regex, "abc"); // not matched! 0
Reg_destroy(regex);
Installing it as a submodule
$ cd <your_project>
$ mkdir -p deps
$ git submodule add git://github.com/txus/libreg deps/libreg
In your Makefile, add this to your CFLAGS:
CFLAGS=<whatever> -Ideps/libreg/include
And this to your LDFLAGS:
LDFLAGS=<whatever> deps/libreg/build/libreg.a
Create a libreg target in your Makefile:
libreg:
$(MAKE) -C deps/libreg
And finally add it as a dependency of your main target:
all: libreg <your> <other> <targets>
Done! :)
Development
To build libreg and run its test suite:
$ git clone git://github.com/txus/libreg
$ cd libreg
$ make
If you want to run with Valgrind to ensure there are no memory leaks:
$ make valgrind
Tested in Mac OSX 10.8 and Linux.
Dependencies
We build the parser using a vendored version of Ian Piumarta's peg/leg library:
http://piumarta.com/software/peg/
Who's this
This was made by Josep M. Bach (Txus) under the MIT license. I'm @txustice on twitter (where you should probably follow me!).
Contributing
- Fork it
- Create your feature branch (
git checkout -b my-new-feature) - Commit your changes (
git commit -am 'Added some feature') - Push to the branch (
git push origin my-new-feature) - Create new Pull Request
Related Skills
node-connect
352.0kDiagnose OpenClaw node connection and pairing failures for Android, iOS, and macOS companion apps
frontend-design
111.1kCreate distinctive, production-grade frontend interfaces with high design quality. Use this skill when the user asks to build web components, pages, or applications. Generates creative, polished code that avoids generic AI aesthetics.
openai-whisper-api
352.0kTranscribe audio via OpenAI Audio Transcriptions API (Whisper).
qqbot-media
352.0kQQBot 富媒体收发能力。使用 <qqmedia> 标签,系统根据文件扩展名自动识别类型(图片/语音/视频/文件)。
