Refactoring and enhancements to regex

Modified the regexes to eliminate a lot of the assertion code. Refactored a few methods in the process.
Note that these changes have not been tested thoroughly. I will add a comment once I have tested all the cases I have refactored. You might want to test these out yourself, or wait till I do so.