加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

正则表达式 – “两级正则表达式”是什么意思?

发布时间:2020-12-14 05:56:51 所属栏目:百科 来源:网络整理
导读:我理解基本的正则表达式,但不确定下面引用的含义(关于如何实现wiki解析器),是否有人可以提供一些伪代码来启发我? Two-level regular expressions This is a very popular approach. It’s pretty fast,as it scans the raw text exactly two times. The ide
我理解基本的正则表达式,但不确定下面引用的含义(关于如何实现wiki解析器),是否有人可以提供一些伪代码来启发我?

Two-level regular expressions

This is a very popular approach. It’s pretty fast,as it scans the raw text exactly two times.

The idea is to create two kinds of regular expressions — one to split the text into blocks of different kinds (paragraphs,headings,lists,preformatted blocks,etc.) and then process each of them with different character-level regular expression.

引用自:http://www.wikicreole.org/wiki/CommonWikiParsingTechniques

解决方法

这意味着不要尝试在单个正则表达式中完成多个任务,而是将其拆分为两个任务(两个级别);首先拆分,然后分别处理每个令牌.

我的观点是,人们经常不必尝试让一个Regex一次做太多,而不是通过分割这样的不同任务来使事情变得更简单.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读