如何解决使用 regEx
我想看,文件夹中的变化:
- test/index.js
- te3st/index.js
但没有变化
- te2st/index.js 不是任何 teNUMBERst/index.js
我使用 chokidar 并从这里获得灵感:chokidar
使用 ignored: ignored: /^.*\b(?:(?!te2st\/index\.js)\w)+\b$/
可以使用 regEx,但我的 regEx 没有按预期工作 (regex how to exclude specific characters or string anywhere)。
这个正则表达式在这里工作: https://regex101.com/r/XnKYcf/1/
var chokidar = require('chokidar');
var watcher = chokidar.watch('/home/replays/0.0.24/t*t/index.js',{ignored: /^.*\b(?:(?!te2st\/index\.js)\w)+\b$/,persistent: true});
watcher
.on('add',function(path) {console.log('File',path,'has been added ');})
.on('change','has been changed ');})
.on('unlink','has been removed ');})
.on('error',function(error) {console.error('Error happened',error);})
那是在这里还不能正常工作的广告否定定义。允许通过正则表达式会更实用且更易于阅读。这可能吗?
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。