var str = "aaabbbcccdddeeefff";
str = str.match(/aaa(\S*)fff/)[1];
alert(str);//结果bbbcccdddeee
实际运用 获取目录内容并将文件夹名称提取出来
const files = require.context('../../components/bar', true, /.vue$/).keys();
console.log(files)
files.forEach((type) => {
this.comps.push(type.match(/.\/(\S*)\/index.vue/)[1])
});
console.log(this.comps)
提取前
['./bar1/index.vue', './bar2/index.vue', './bar3/index.vue']
提取后
['bar1', 'bar2', 'bar3']