Reworked matching at end for regex implementation.