Javascript 使用正则表达式查看文件夹中的文件已更改
我要查看文件夹中的更改:Javascript 使用正则表达式查看文件夹中的文件已更改,javascript,chokidar,Javascript,Chokidar,我要查看文件夹中的更改: test/index.js te3st/index.js 但这不是变化 te2st/index.js没有任何teNUMBERst/index.js 我使用chokidar并从中获得灵感: 忽略时:忽略:/^.*\b(?(?!te2st\/index\.js)\w)+\b$/可以使用正则表达式,但我的正则表达式没有按预期工作() 这个正则表达式在这里工作: 这就是广告负面的定义,在这里还不能正常工作。允许通过正则表达式(via regex)将更加实用,也更易于阅
- test/index.js
- te3st/index.js
- te2st/index.js没有任何teNUMBERst/index.js
时:忽略:/^.*\b(?(?!te2st\/index\.js)\w)+\b$/
可以使用正则表达式,但我的正则表达式没有按预期工作()
这个正则表达式在这里工作:
这就是广告负面的定义,在这里还不能正常工作。允许通过正则表达式(via regex)将更加实用,也更易于阅读。这可能吗?这个答案实际上没有使用忽略属性。它首先允许几乎任何东西,然后再过滤。也许作为一个带有ignore属性的解决方案更容易理解,我还没能用它来实现它
var chokidar = require('chokidar');
var watcher = chokidar.watch('/home/x/0.24/t*t/index.js',{ignored: /$^/, persistent: true}); // /$^/ is match nothing
watcher
.on('add', function(path) {
if(path.match(/te(|3)st\/index\.js/)){
console.log('File', path, 'te(||3)st found :) ');
}
})
$node/home/x/0.0.24/file watcher.js的输出
File /home/x/0.0.24/te3st/index.js te(||3)st found :)
File /home/x/test/index.js te(||3)st found :)
目前的解决方法是:crontab-e
*/2****php~/doIt.php
,通过正则表达式过滤读取完整文件夹
File /home/x/0.0.24/te3st/index.js te(||3)st found :)
File /home/x/test/index.js te(||3)st found :)