Awesome Open Source
Awesome Open Source


Apache-2.0 Build Status codecov Downloads Commit Gitter

See the usage documentation.

A short example below shows how comby simplifies matching and rewriting compared to regex approaches like sed.

Comby supports interactive review mode (click here to see it in action).

Need help writing patterns or have other problems? Post them in Gitter.

Install (pre-built binaries)

Mac OS X

  • brew install comby

Ubuntu Linux

  • bash <(curl -sL

  • Other Linux distributions: The PCRE library is dynamically linked in the Ubuntu binary. For other distributions like Arch Linux, a fixup is needed: sudo ln -s /usr/lib/ /usr/lib/ On Fedora, use sudo ln -s /usr/lib64/ /usr/lib64/ Alternatively, consider building from source.



  • docker pull comby/comby
click to expand an example invocation for the docker image

Running with docker on stdin:

docker run -a stdin -a stdout -a stderr -i comby/comby '(:[emoji] hi)' 'bye :[emoji]' lisp -stdin <<< '(👋 hi)'

Or try it live.

Isn't a regex approach like sed good enough?

Sometimes, yes. But often, small changes and refactorings are complicated by nested expressions, comments, or strings. Consider the following C-like snippet. Say the challenge is to rewrite the two if conditions to the value 1. Can you write a regular expression that matches the contents of the two if condition expressions, and only those two? Feel free to share your pattern with @rvtond on Twitter.

if (fgets(line, 128, file_pointer) == Null) // 1) if (...) returns 0
      return 0;
if (scanf("%d) %d", &x, &y) == 2) // 2) if (scanf("%d) %d", &x, &y) == 2) returns 0
      return 0;

To match these with comby, all you need to write is if (:[condition]), and specify one flag that this language is C-like. The replacement is if (1). See the live example.

Build from source

  • Install opam. TL;DR do sh <(curl -sL

  • Run this if you don't have OCaml installed (it bootstraps the OCaml compiler):

opam init
opam switch create 4.11.0 4.11.0
  • Run eval $(opam env)

  • Install OS dependencies:

    • Linux: sudo apt-get install autoconf libpcre3-dev pkg-config zlib1g-dev m4 libgmp-dev libev4 libsqlite3-dev

    • Mac: brew install pkg-config gmp pcre libev

  • Then install the library dependencies:

git clone
cd comby 
opam install . --deps-only
  • Build and test
make test
  • Install comby on your PATH by running
make install
Related Awesome Lists
Top Programming Languages
Top Projects

Get A Weekly Email With Trending Projects For These Topics
No Spam. Unsubscribe easily at any time.
Javascript (1,061,137
Python (808,558
Java (388,822
Php (286,134
Typescript (247,243
C (182,208
Go (158,480
Docker (97,330
Swift (65,285
Rust (57,759
Parsing (28,930
Syntax (11,126
Linting (9,088
Regex (8,807
Ocaml (6,709
Refactoring (2,073
Reason (1,876
Parser Combinators (397
Code Search (151
Rewriting (24
Search And Replace (20
Program Transformation (16
Syntax Transformation (4