regex - 选择所有以一个字符开头的行并只保留一个条目
问题描述
我正在使用一个名为“rikaisama”的firefox插件,这个插件是一个弹出式日语词典,它允许使用epwing词典文件。在插件选项中,我们可以使用一个正则表达式来删除字典条目中不必要的部分。
我正在使用“Kenkyusha 的新日英词典”epwing 文件,但它有太多示例无法阅读。
条目示例:
まにあう【間に合う】 ローマ(maniau)
1 〔時間に遅れない〕 be in time 《for…》.
▲7 時の列車に間に合う catch [make] the 7 o'clock train
・締め切りに間に合う meet the deadline
・開演に間に合う arrive before curtain time
▲9 時の札幌行きに間に合うように空港に着いた. I arrived in time for the nine o'clock flight to Sapporo.
・「間に合うかな」「走っても間に合いそうにないね」 "Will we be in time?"―"It doesn't look like we'll be in time even if we run."
2 〔役に立つ〕 answer [serve, suit, meet] the purpose; be useful; be serviceable; be of use [service]; be good enough; 〔十分である〕 be enough; 〔用意ができる〕 be ready; 〔必要をみたす〕 meet the requirements; serve the [one's] turn [need].
▲「費用はどのぐらいかな」「5 万もあれば間に合うよ」 "And what is the expense?"―"Fifty-thousand yen should cover it."
・これだけあれば丸 1 年は間に合う. This will last us [see us through] one whole year. | This will be enough for a whole year.
其中以“▲”或“・”开头的所有条目都是示例,与此正则表达式匹配的所有条目都是定义:
\n[″*〖〈《⇒=➡【〔(〜A-Za-z0-9].*
我已经设法自己提出了这个正则表达式,但它删除了所有示例:
\n[^″*〖〈《⇒=➡【〔(〜A-Za-z0-9].*
是否有可能有一个匹配这个正则表达式的正则表达式和匹配的以下行?
希望的结果:
まにあう【間に合う】 ローマ(maniau)
1 〔時間に遅れない〕 be in time 《for…》.
▲7 時の列車に間に合う catch [make] the 7 o'clock train
2 〔役に立つ〕 answer [serve, suit, meet] the purpose; be useful; be serviceable; be of use [service]; be good enough; 〔十分である〕 be enough; 〔用意ができる〕 be ready; 〔必要をみたす〕 meet the requirements; serve the [one's] turn [need].
▲「費用はどのぐらいかな」「5 万もあれば間に合うよ」 "And what is the expense?"―"Fifty-thousand yen should cover it."
任何帮助表示赞赏!
解决方案
我想你几乎拥有它 - 只需添加\n.*
它就可以了/\n[″*〖〈《⇒=➡【〔(〜A-Za-z0-9].*\n.*/
。这使得它得到下一行......
在此处查看实际操作:https ://regexr.com/442st
推荐阅读
- sql-server - 客户端如何通过 SQL Server 解密 AES 加密文件
- idl-programming-language - IDL lambda:尝试下标超出范围
- reactjs - 如何将 this.props.match.params.id 传递给无服务器函数以从 React Web 应用程序查询数据库
- google-sheets - 如何使用动态工作表名称安装公式
- javascript - 在 Typescript 中仅接受字符串密钥对值的通用对象
- html - 如何对齐 DIV 以创建一个看起来像搜索框的框
- reactjs - 在 React TypeScript 中循环遍历整个 div
- php - 使用 json_encode 将值从 PHP 传递到 Ajax 时出现意外结果
- python - 我想从bubble_list 中提取menu_header,然后只需要从menu_list 中提取条件类型='menu' 的所有标题
- ios - 应用程序被杀死时,如何每 10 秒将用户位置上传到服务器?