Use RegExp::test rather than String::search, fixing a logic error