added tests, fixed some bugs, added regex format