Code Monkey home page Code Monkey logo

regex's Introduction

regex

What is this?

A header-only lightweight regex library for C++17.

What can it do?

It allows you to search or match constructed regexes against input.

What regex operators are available?

  • Kleene Star, *
  • Boolean OR, |
  • Grouping, ( )

You can escape operators with \.

Usage

Instantiation:

rgx::Regex<> re("(a\\*b*)*c*\\+\\*");

Matching:

A.match("a*bbbbcccccc+*");    // will match

Searching:

A.search("a*bbbbcccccc+***aaa*bbbbcccccc+***aa");    // will find 2 occurences at index 0 and 18

Some details

The library should be fairly portable as it uses std::locale(). For the same reason, it is NOT a compile-time library (look into CTRE if you're interested in that).

Unlike other, this implementation doesn't build the corresponding DFA for the given regular expression. Instead, it uses Glushkov's construction to build an NFA with it's states being represented by bitsets. This allows us to not have to build the DFA (which might end up being very large) but still be able to virtually parse it thanks to bitwise operations on the current transition without losing significant performance.

For the bitmasking of states my own implementation of a dynamic bitset was also used.

Should you use this?

No. At the moment this is just a for fun project. Extensive testing/benchmarking has not been performed and the features don't really hold up to other libraries.

regex's People

Contributors

pridestalkerr avatar

Stargazers

 avatar  avatar  avatar  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.