Friday 15 May 2015

php - How to create loop with regular expression? -


Honestly, I think you should first ask for help with the syntax of this question.

But if you can understand what I want to say, edit the title with the appropriate title.

Is there a way to create such a pattern, which can divide a lesson like this. {{START}} {{START}} {{START}} {{END}} {{END}} {{END}} {{END}}

So every {{START}} matches the last time from {{END}} to the last!

And if I can not do it with just regex, what is this about using PHP?

You are welcome.

This is beyond the ability of regular expression, which can parse only regular grammar what you describe A pushdown will be required by automaton (regular languages ​​are defined by one).

You can use regular expressions to parse the individual elements, but with a concept of "language depth" AA language memory (PHP is fine for it).

In your solution, regexes will be used only to identify your tag, whereas the actual logic should be programmed to monitor the depth and what element belongs to the end tag.

No comments:

Post a Comment