This could be simplified to `/^\b|\b$/.test(pattern)`, couldn't it?