const regex = /static.*/g;
const str = `src\\main\\webapp\\static\\ca7ecd95-aa95-4da8-b369-92b66b566958\\icon.png`;
let m;
while ((m = regex.exec(str)) !== null) {
// This is necessary to avoid infinite loops with zero-width matches
if (m.index === regex.lastIndex) {
regex.lastIndex++;
}
// The result can be accessed through the `m`-variable.
m.forEach((match, groupIndex) => {
console.log(`Found match, group ${groupIndex}: ${match}`);
});
小葫芦 2017-07-05 10:55:536楼
赞 +0添加回复
怪我咯 2017-07-05 10:55:535楼
split('static')[1] 这样的吗? 还是必须用正则?
赞 +0添加回复
欧阳克 2017-07-05 10:55:534楼
str.slice(str.search(/static/));
赞 +0添加回复
phpcn_u1582 2017-07-05 10:55:533楼
正则应该用 static.* 就可以,下面是参考代码
赞 +0添加回复
ringa_lee 2017-07-05 10:55:532楼
'srcmainwebappstaticca7ecd95-aa95-4da8-b369-92b66b566958icon.png'.split('static')[1]
赞 +0添加回复
曾经蜡笔没有小新 2017-07-05 10:55:531楼
这个问题的亮点:
赞 +0添加回复