我理解基本的正则表达式,但不确定下面引用的含义(关于如何实现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一次做太多,而不是通过分割这样的不同任务来使事情变得更简单.