Fixed some bugs in matchDocs which caused errors when matching against RegExp.