Regular Expressions Gym

Slim your regexes one step at a time!

① Define regex

Enter a regular expression into the input field below or click Generate random regex to have the app generate a simple regex randomly for you.

A valid regex consists of alphanumeric characters representing the set of input symbols (e.g. a, B, 9), the $ character representing the empty string, the choice operator +, the Kleene operator *, and parentheses ( and ). An example of a valid regex is: (a+B)*(c9+$)+$.

② Simplify regex

Click Simplify step to perform one simplification step, and Simplify full to perform simplification until the end.

Using set algebra and FSM equivalence laws, regex simplification reduces the length of the regex definition string while not changing the language that the regex defines. For example, the regex (a+aa)* defines the same language as the regex a*.

③ Simplification history

For each simplification step, the application gives the regex strings before and after the simplification step, and the generic rule that was used to perform the step. Furthermore, the application highlights the characters that were deleted in each simplification step.

④ What's next?

This is just the beginning! If you like learning about and playing with FSMs and regexes, check out these other Web apps:

⑤ Feedback

Love the application, hate it, found a bug, or have a feature idea? I'd love to hear about it! Please send your feedback via the noam project issues page on GitHub.