https://github.com/cbritopacheco/my-regex
Custom regular expression engine
https://github.com/cbritopacheco/my-regex
cpp regex
Last synced: over 1 year ago
JSON representation
Custom regular expression engine
- Host: GitHub
- URL: https://github.com/cbritopacheco/my-regex
- Owner: cbritopacheco
- License: gpl-3.0
- Created: 2017-03-22T03:32:18.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2021-09-30T18:38:27.000Z (almost 5 years ago)
- Last Synced: 2025-01-11T00:46:00.919Z (over 1 year ago)
- Topics: cpp, regex
- Language: C++
- Homepage:
- Size: 747 KB
- Stars: 0
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: License
Awesome Lists containing this project
README
# What is it?
This is a Regex engine that matches a string like `abbccccaa` to a pattern like `a+b*(cc)*aa`.
It does this by building a Non-Deterministic Finite Automata out of the given regular expression and recursively
emulating the automata.
# Basic usage
````cpp
#include
#include "src/Regex/Regex.h"
using namespace std;
int main() {
Regex::Regex regex("aaa(a|b)+c*");
cout << "Match? " << regex.match("aaabbababacc") << endl;
return 0;
}
````
Output:
`~ $ Match? 1`
# How-to use
Please see the Examples/ directory for examples on how to use the code. Each subfolder will have an explanation.
# Building
To build the project you just have to clone the repo using
`git clone https://github.com/carlosb/regexp-to-automata`
Navigate to the directory where you cloned:
`cd dir_where_you_cloned`
Type in:
````
cmake .
cd cmake-build-debug
make
````
And to execute:
`./MyRegex`
# Notes on Building
This project is coded using C++11 syntax. This should be set in CMakeLists.txt if using CMake with the flag
`set(CMAKE_CXX_STANDARD 11)`