Q:

How to Figure Out the Regular Expression

I know that there is a way to figure out the regular expression yourself based on tree you build.  For example, you can build the tree that represent all cases of complex numbers (i.e., a+bi, bi+a, ...), then based on the built tree, you can find out the regular expression for complex numbers.  This method is part of building compiler for syntax analysis.  However, I do not remember how it was done.  Can anyone help with examples? 

A:

After searching, I have found it.  The tree is called Parse Tree.  See the following link:
Compiler Design - Syntax Analysis
However, it seems writing a regular expression straight away is easier.  I think this can be used to build a procedure to validate an expression without using Regex class.