let reg = /news\/(sub\/)?[-a-z.0-9_]/; let arr = ['news/-', 'news/sub/_','news/.','news/?'].map(e => reg.test(e)); alert(arr);