Giter Club home page Giter Club logo

regexp-1's Introduction

RegExp

Easier CPP interface to PCRE regex engine with global match and replace.

I was looking around for better regex engine than regcomp for my C/C++ apps. I found PCRE (Perl Compatible Regular Expression, http://pcre.org/) and am very happy with it. It is very fast. PCRE is a C library and has an excellent API (see pcredemo.c in PCRE library source code). There is also a PCRECPP API but I didn't really like that. It isn't consistent with the C API and seems overly complex.

The RegExp API is easier to use and is very efficient. It makes it easy to find multiple matches. You can also easily access captures and named captures. You can replace captures and named captures with new substrings. It works with const char* and std::string. You can copy a string into the object an operate on it, or you can have the object reference an external string.

You only need two files (regexp.h and regexp.cpp) that you can include in your own code.

It does depend on PCRE to be installed on your system. Download PCRE from http://pcre.org/ and build it. I did the following:

./configure CFLAGS=-Dregcomp=PCREregcomp
--prefix=/usr
--docdir=/usr/share/doc/pcre-8.35
--enable-unicode-properties
--enable-pcre16
--enable-pcre32
--enable-pcregrep-libz
--disable-static make make install

Take a look at test.cpp for quick sample code. To build the test app, simply type make in the src directory.

Also, http://regex101.com/#pcre is an excellent resource for learning regular expression. You can test PCRE expressions the website, and then cut and paste into your regexp code.

Build! Go!

regexp-1's People

Contributors

diggidydave avatar yasserasmi avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.