Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/zhztheplayer/DFA-Regex
A DFA regex engine in java.
https://github.com/zhztheplayer/DFA-Regex
dfa-regex java redos regex
Last synced: 7 days ago
JSON representation
A DFA regex engine in java.
- Host: GitHub
- URL: https://github.com/zhztheplayer/DFA-Regex
- Owner: zhztheplayer
- License: other
- Created: 2015-05-14T02:13:18.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2024-08-03T07:47:15.000Z (3 months ago)
- Last Synced: 2024-08-03T16:49:34.928Z (3 months ago)
- Topics: dfa-regex, java, redos, regex
- Language: Java
- Homepage:
- Size: 52.7 KB
- Stars: 58
- Watchers: 2
- Forks: 17
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# DFA-Regex ![](https://travis-ci.org/zhztheplayer/DFA-Regex.svg?branch=master)
A DFA regex engine in java.
### Pom Settings
```xmltop.yatt.dfargx
dfargx
0.2.1```
### IntroductionThis is a Java DFA regex engine implementation.
- High compatibility -- single jar lib, without 3rd dependencies
- High performance -- O(n) liner time complex, can be used for avoiding [ReDoS](https://en.wikipedia.org/wiki/ReDoS)### Use Case
```java
RegexMatcher matcher = new RegexMatcher("\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}");
boolean result = matcher.match("192.168.0.255"); // return true or false, should be true in this case.
```
### Performance Comparison With JDK Regex:Below is showing a typical [ReDoS](https://en.wikipedia.org/wiki/ReDoS) attack input against a fragile regex pattern.
Regex | Input | Time Cost (Java Native) | Time Cost (DFA Regex)
:-----:|:------:|:-------------------------:|:------------:
(a\*)\*|aaaaaaaaaaaaaaaaab|42ms|12ms
(a\*)\*|aaaaaaaaaaaaaaaaaaaaaaab|311ms|1ms
(a\*)\*|aaaaaaaaaaaaaaaaaaaaaaaaaaaab|9579ms|1ms### Supported Features:
- matching
- searching
- ascii character set
- `*`, `+`, `?`, `{x}`, `{x,y}`, `{x}`
- `.`, `\w`, `\W`, `\s`, `\S`, `\d`, `\D`
- complementary set `[^a]`
- escape characters
- brackets### Todo List:
- [POSIX-Extended Regex](http://www.boost.org/doc/libs/1_44_0/libs/regex/doc/html/boost_regex/syntax/basic_extended.html) syntax support
- Liner time searching