Skip to content
forked from jserv/cregex

A small implementation of regular expression matching engine in C

License

Notifications You must be signed in to change notification settings

wiasliaw/cregex

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

21 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

cregex

cregex is a compact implementation of regular expression (regex) matching engine in C. Its design was inspired by Rob Pike's regex-code for the book "Beautiful Code" available online here. It is based on two papers by Russ Cox:

cregex supports a subset of the syntax and semantics of the POSIX Basic Regular Expressions. The main design goal of cregex is to be small, correct, self contained and use few resources while retaining acceptable performance and feature completeness.

Features

  • ^ and $ anchors
  • . match any single character
  • [...] and [^...] character classes
  • ?, *, +, and {x,y} greedy quantifiers
  • ??, *?, +?, and {x,y}? non-greedy quantifiers
  • (...) capturing groups

Build and Test

Simply run to build the library and test programs.

$ make

Run the tests from Go distribution.

$ make check

Visualize the regular expressions with Graphviz.

$ tests/re2dot "(a*)(b{0,1})(b{1,})b{3}" | dot -Tpng -o out.png

License

cregex is freely redistributable under the BSD 2 clause license. Use of this source code is governed by a BSD-style license that can be found in the LICENSE file.

About

A small implementation of regular expression matching engine in C

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • C 87.2%
  • Ruby 9.1%
  • Makefile 3.7%