The RegexToStateMachine project is a educational project that shows how to transfer a subset of regular expressions to a state machine and how to use that generated statemachine to check an overtaken text against the generated state machine.

The commands to generate the state machine are:
  • c - Matches any literal character c
  • . - Matches any single character
  • * - Matches one or more occurrences of the previous character
  • () - Brackets to group the characters
  • | - Logical or
Here is a code example that shows how to use RegexToStateMachine:

StateMaschineBuilder stateMaschineBuilder = new StateMaschineBuilder();
StateMaschine stateMaschine = stateMaschineBuilder.Match("((AB|EF)*GH)I");
var result = stateMaschineBuilder.Recognize("ABABEFEFGHI", stateMaschine);

There is an blog post at my blog http://netmatze.wordpress.com/2013/02/21/implementing-a-regular-expression-to-state-machine-parser-part-1-introduction/ that describes the steps to build a state machine out of a specific text.

Last edited Feb 26, 2013 at 3:14 PM by netmatze, version 4