Skip to content
Deterministic Regular Expressions with Backreferences
Java TeX ANTLR
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
benchmark
cli
documentation
engine
json
lucene
presentation
.gitignore
LICENSE
README.md
pom.xml

README.md

moar

Deterministic Regular Expressions with Backreferences. Uses Memory Occurrence Automata to match the input.

ANTLR is used for Pattern compilation.

Why?

Java's Patterns are not deterministic and might get you into trouble. All deterministic alternatives don't support backreferences. This library does. This however is no drop in replacement for Java's patterns as some things can not be expressed while keeping the determinism.

Technical documentation

The technical documentation can be found in the documentation folder.

Theoretical Background

I held a talk at university covering the basics of this library as well. It can be found in the presentation folder.

A Paper explaining the theoretical background can be found here.

Supported Syntax

While somewhat similar to Java's Pattern syntax, moar's supported syntax might differ in some cases. The full supported Pattern syntax can easily be seen in the ANTLR grammar:

Examples

MoaPattern pattern = MoaPattern.compile("^Deterministic|OrNot$");
MoaMatcher matcher = pattern.matcher("Deterministic");
if ( matcher.matches() ) {
  System.out.println("yay");
}

Or this cool language:

MoaPattern pattern = MoaPattern.compile("((?<y>\\k<x>)(?<x>\\k<y>a))+");
MoaMatcher matcher = pattern.matcher("aaaa");
if( matcher.matches() ) {
  System.out.println("yay again.");
}
You can’t perform that action at this time.