比如说我想让字符串"2014年法律硕士考试提醒"匹配的结果为"法律硕士考试提醒"。如果可以用后发断言的话就直接"(?<=2014年).+"就行了。
现在怎么解决...
var s = '2014年法律硕士考试提醒',
pos = s.indexOf('2014年'),
mt = (pos >= 0 ? s.substr(pos+5):'');
直接 /2014年(.+)/
不可以么...
var str = '2014年法律硕士考试提醒';
str.match(/2014年(.*)/g)
var matchResult = RegExp.$1;
然后matchResult就是你想要匹配的结果了。