If you want to test for regexp use util.isRegExp. There is no reason to test if text has function .test