Class Regex
java.lang.Object
it.tugamer89.autogex.regex.Regex
Facade class representing a compiled Regular Expression. Under the hood, it parses the regex, builds an ENFA, converts it to a DFA, and minimizes it.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionRetrieves the underlying compiled and minimized DFA.Retrieves the original regular expression pattern.booleanChecks if the input string perfectly matches the regular expression.Exports the compiled minimal DFA to the Graphviz DOT language format.Exports the compiled minimal DFA to the Mermaid.js stateDiagram-v2 format.
-
Constructor Details
-
Regex
Compiles the given regular expression into a highly optimized Minimal DFA.- Parameters:
pattern- The regular expression string (e.g., "(a|b)*abb").- Throws:
IllegalArgumentException- If the regex syntax is invalid.
-
-
Method Details
-
matches
Checks if the input string perfectly matches the regular expression.- Parameters:
input- The string to test.- Returns:
- True if the string is accepted by the underlying automaton, false otherwise.
-
toDotGraph
Exports the compiled minimal DFA to the Graphviz DOT language format. This string can be rendered using Graphviz tools or online viewers.- Returns:
- The DOT graph representation.
-
toMermaidGraph
Exports the compiled minimal DFA to the Mermaid.js stateDiagram-v2 format. This string can be natively rendered in GitHub Markdown without external viewers.- Returns:
- The Mermaid.js graph representation.
-
getAutomaton
Retrieves the underlying compiled and minimized DFA.- Returns:
- The minimal DFA.
-
getPattern
Retrieves the original regular expression pattern.- Returns:
- The pattern string.
-