Optimized code by converting overkill string.match() to regexp.test()