var re = /(hi)?/g;console.log(re.exec("hi")); // ["hi", "hi"]不加则为null:
r=/(a)/gr.exec('www') // null有?情况:
r=/(a)?/gr.exec('www') // ["", undefined, index: 0, input: "www", groups: undefined]
只有?的情况:
r=/a?/gr.exec('www') // ["", index: 0, input: "www", groups: undefined]
匹配零次
r=/,{0}/gr.exec('www') // ["", index: 0, input: "www", groups: undefined]
慕盖茨4494581
LEATH
随时随地看视频慕课网APP
相关分类