我正在尝试编写正则表达式以在命令未使用绝对路径的文件中查找行。不幸的是,这些行存在间距问题。
// PATHS
pathmunge /absolute/path
pathmunge ~not/absolute/path
pathmunge /absolute/path
// matches
pathmunge ~not/absolute/path
我的表达式匹配pathmunge
字符串开头和之前有空格的行,但是它找不到长度可变的空格但下一个非空格字符没有“ /”的行
到目前为止,我有:
^(?=\s+pathmunge)\s+(?!\/).*$
感谢您的帮助。
答案 0 :(得分:1)
对于正则表达式,我会这样做:
^(?:[[:blank:]]*pathmunge[[:blank:]]+([^\s\/].*$))
关键元素是[^\s\/]
,它与除水平空格或任何绝对路径开头的\n
或/
以外的单个字符相匹配。
答案 1 :(得分:1)
删除前瞻并使空间具有所有权:
var one = 1,
two = 2,
three = 3;
function bom (one,two, three){
console.log(one,two,three);
return function b(){
console.log(`From closure ${one}`);
};
};
let myClosureFn = bom(1, 2, 3 );
myClosureFn();