Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/467.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

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 使用正则表达式重写url_Javascript_Regex_Gruntjs - Fatal编程技术网

Javascript 使用正则表达式重写url

Javascript 使用正则表达式重写url,javascript,regex,gruntjs,Javascript,Regex,Gruntjs,我有以下url重写规则 var aURLRewrites = [ { from: "^/ps/app/ui/res/(.*)$", to: "/bower_components/sapui5/$1" }, { from: "^/ps/app/ui(?:/|(?:/index.html))?(?:\\?.*|$)", to: "/demo/index.html"

我有以下url重写规则

 var aURLRewrites = [
        {
            from: "^/ps/app/ui/res/(.*)$",
            to: "/bower_components/sapui5/$1"
        }, {
            from: "^/ps/app/ui(?:/|(?:/index.html))?(?:\\?.*|$)",
            to: "/demo/index.html"
        }, {
            from: "^/ps/app/ui/(.*)$",
            to: "/src/$1"
        }, {
            from: "^/ps/specs/unit/(.*)$",
            to: "/specs/unit/$1"
        }, {
            from: "^/ps/specs/integration/(.*)$",
            to: "/specs/integration/$1"
        }, {
            from: "^/ps/demo/(.*)$",
            to: "/demo/$1"
        }
    ];
现在的问题是,它们是静态的,比如说,它们可以像。。。 但我希望所有重写规则都可以使用/ps/app/ui后面的任何路径访问,例如。。。也应该有效。而且原始url也必须工作。
有人知道如何在/ps/app/ui之前添加正则表达式吗?

在规则前面加上
(?:/\w+)*


对不起,我没有成功
^(?:/\w+)*/ps/app/ui/res/(.*)$