Javascript 在grunt contrib copy中使用正则表达式';s";过程“;选项不起作用
我正在尝试使用Grunt的复制插件动态地从index.html文件中删除我的live reload脚本 我的Gruntfile中包含相关代码的部分如下所示:Javascript 在grunt contrib copy中使用正则表达式';s";过程“;选项不起作用,javascript,regex,gruntjs,grunt-contrib-copy,Javascript,Regex,Gruntjs,Grunt Contrib Copy,我正在尝试使用Grunt的复制插件动态地从index.html文件中删除我的live reload脚本 我的Gruntfile中包含相关代码的部分如下所示: copy: { main: { files: [ { expand: true, src: 'index.html', dest:
copy: {
main: {
files: [
{
expand: true,
src: 'index.html',
dest: 'build/',
options: {
process: function (content, srcpath){
return content.replace(/<script src = "http:\/\/localhost:9090\/livereload.js"><\/script>/g, " ");
}
}
},
复制:{
主要内容:{
档案:[
{
是的,
src:'index.html',
dest:'build/',
选项:{
进程:函数(内容、路径){
返回内容。替换(//g,“”);
}
}
},
我检查了一个正则表达式测试程序,结果显示上面的正则表达式应该与html中的脚本匹配
尽管regex测试人员说这是合法的,但我以前的匹配结果不准确,因此我需要帮助确定Grunfile或正则表达式是否存在问题。有什么建议吗?您的选项放错了位置,它们需要更高一级:
copy: {
main: {
files: [
{
expand: true,
src: 'index.html',
dest: 'build/'
},
options: {
process: function (content, srcpath){
return content.replace(/<script src = "http:\/\/localhost:9090\/livereload.js"><\/script>/g, " ");
}
}
复制:{
主要内容:{
档案:[
{
是的,
src:'index.html',
dest:'build/'
},
选项:{
进程:函数(内容、路径){
返回内容。替换(//g,“”);
}
}