Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/regex/19.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 在grunt contrib copy中使用正则表达式';s";过程“;选项不起作用_Javascript_Regex_Gruntjs_Grunt Contrib Copy - Fatal编程技术网

Javascript 在grunt contrib copy中使用正则表达式';s";过程“;选项不起作用

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:

我正在尝试使用Grunt的复制插件动态地从index.html文件中删除我的live reload脚本

我的Gruntfile中包含相关代码的部分如下所示:

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,“”);
}
}