I understand basic regular expression, but unsure what the below quote means (regarding how to implement a wiki parser), could anyone provide some pseudo code to enlighten me?
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.
Quote from: http://www.wikicreole.org/wiki/CommonWikiParsingTechniques
It means not trying to accomplish multiple tasks in a single Regex, but to split it into two tasks (two levels); splitting first, then handling each token separately.
My opinion is that people often unecessarily try to have a single Regex do too much at once, instead of making things much simpler by splitting different tasks like this.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With