var str = "YYYY-mm-dd" var opt = /(Y+)/ var opt2 = /Y+/ opt.exec(str) //[ ‘YYYY‘, ‘YYYY‘, index: 0, input: ‘YYYY-mm-dd‘, groups: undefined ] opt2.exec(str) //[ ‘YYYY‘, index: 0, input: ‘YYYY-mm-dd‘, groups: undefined ]
为什么会这样,两个的区别在哪里?
原文:https://www.cnblogs.com/ilfish/p/15089986.html