Regular Expressions to NFA's by Thompson's Construction in Javascript