Fix OK but the performance is not

The fixed routine takes twice the time probably because it instantiates a Regexp every time incurring regexp compilation penalty every time the method is called.