Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/sang-it/t_rex
NFA / DFA based Regex Engine in TS.
https://github.com/sang-it/t_rex
dfa finite-state-machine nfa regex
Last synced: 10 days ago
JSON representation
NFA / DFA based Regex Engine in TS.
- Host: GitHub
- URL: https://github.com/sang-it/t_rex
- Owner: Sang-it
- License: mit
- Created: 2024-01-07T20:15:01.000Z (about 1 year ago)
- Default Branch: main
- Last Pushed: 2024-01-10T07:20:39.000Z (about 1 year ago)
- Last Synced: 2024-12-16T20:47:01.128Z (about 1 month ago)
- Topics: dfa, finite-state-machine, nfa, regex
- Language: JavaScript
- Homepage:
- Size: 47.9 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
T_REX
NFA/DFA based Regex Machine
Table of Contents
## About The Project
I always wanted to know how Regular Expressions worked. That took me down this deep rabbit hole of Formal Grammar, Chomsky Hierarchy, Kleene Star and etc.
I also had been learning Haskell at the time and the concept of Finite State Machine came up time and again. It turns out I can utilize FSA to implement Regex Engines. So I did.
## Getting Started
Install through your favorite package manager to get started.
### Installation
```sh
npm install @rux12/t_rex
```
```sh
yarn add @rux12/t_rex
```## Usage
Basic Usage:
```ts
import {build} from "@rux12/t_rex";const re = build("/(ab|cd)/");
re.matches("ab") // true
re.matches("cd") // true
re.matches("ef") // false
```
You could also use the builders provided.
```ts
import {char, or} from "@rux12/t_rex";const re = or(
char("a"),
char("b")
);re.matches("a") // true
re.matches("b") // true
re.matches("e") // false
```## Roadmap
- [ ] Add Wildcard Support (for now)
## Contact
Email: [email protected]
Project Link: [https://github.com/Sangi-it/t_rex](https://github.com/Sang-it/t_rex)
## Acknowledgments
* [regex-tree](https://github.com/DmitrySoshnikov/regexp-tree)