javascript - 正则表达式导致 chrome 挂起 - JS
问题描述
我有一个搜索方法,我正在动态创建一个正则表达式。
例如:搜索词=“一个词”。
正则表达式如下所示:
(\\s*<[^>]+>\\s)*three(\\s*<[^>]+>\\s)*four
由于某种原因,它导致 chrome 浏览器挂起。
解决该问题的任何帮助将不胜感激
[编辑]
搜索到的区域如下所示:
<span id="1" title="bbox 483 1557 715 1602; x_wconf 96"><strong><em>one</em></strong></span>
<span id="2" title="bbox 738 1557 986 1592; x_wconf 77"><strong><em>two</em></strong></span>
<span id="3" title="bbox 483 1557 715 1602; x_wconf 96"><strong><em>thre</em></strong></span>
<span id="4" title="bbox 738 1557 986 1592; x_wconf 77"><strong><em>four</em></strong></span>
<span id="5" title="bbox 483 1557 715 1602; x_wconf 96"><strong><em>five</em></strong></span>
<span id="6" title="bbox 738 1557 986 1592; x_wconf 77"><strong><em>six</em></strong></span>
因此,如果我正在寻找“三四”,我应该收到这两个元素:
<span id="3" title="bbox 483 1557 715 1602; x_wconf 96"><strong><em>three</em></strong></span>
<span id="4" title="bbox 738 1557 986 1592; x_wconf 77"><strong><em>four</em></strong></span>
解决方案
推荐阅读
- docker-compose - 关于在 Docker-Compose 中设置 Apache Ignite 的问题
- angular - 在 tomcat 上部署 Maven Angular 6
- php - 多维数组和合并列上的重复值
- node.js - 如何在 Node Js 应用程序中创建应用程序变量
- pdf - 使用 Select.Pdf 填写 PDF 表单
- reactjs - React 服务器端渲染 - 生成不同的 html 服务器端到客户端的性能影响是什么?
- selenium-webdriver - 量角器 - 由于固定的顶部导航栏,无法访问元素
- vue.js - VueJS:如何每个周期渲染几个元素?
- php - 从mysql数据库的while循环中创建具有相同键的数组 - 如何处理重复键?
- angular - 禁用相关日期选择器 Angular Power Bootstrap angular 6