javascript - 积极的前瞻在浏览器的控制台中不起作用,但在 regxr.com 中起作用
问题描述
以下 2 个正则表达式按我的预期工作,在 www.regxr.com 如果我在浏览器的控制台中运行示例,则匹配似乎忽略了积极的前瞻。这是否意味着浏览器(chrome)不支持它?
let regex1 = new RegExp(/(?<=uploaded\s+).*(?=\s+new file)/gi);
let regex2 = new RegExp(/(?<!-)\d+(?=\s+-)/gi);
let input = 'Hi UPR, ' +
'Ryan Anderson uploaded one new file to your request for Fname Lname - 743245 - CS4:' +
'Ryan Anderson - Screen Shot 2020-06-08 at 1.10.39 pm.png ' +
'See new files'
let matches = [];
while ((matches = regex1.exec(input)) !== null) {
console.log(`Found [${matches[0]}]. Next starts at ${regex1.lastIndex}.`);
}
解决方案
推荐阅读
- c++ - 尾随返回类型的名称查找和类型简化规则是什么?
- javascript - 在 tinymce 内容上执行 javascript (katex)
- mysql - 在 MATCH() AGAINST() 中查找匹配列的名称或别名
- ios - 在 iOS 上获取通知正文?
- c++ - 对指针及其地址感到困惑
- c# - 我真的不明白为什么在我输入代码后它什么也没做
- c# - 如果条件不起作用,则在 for 循环内部?
- core-data - Core Data + CloudKit 集成,大二进制文件同步崩溃
- azure-devops - 试图通过限制站点的代理运行 VSTS 代理
- java - RuntimeException 找不到布局 XML 资源