Python 3 regex?

Chris Angelico rosuav at gmail.com
Mon Jan 12 15:32:06 EST 2015


On Tue, Jan 13, 2015 at 6:48 AM, Ian <hobson42 at gmail.com> wrote:
> My recommendation would be to write a recursive decent parser for your
> files.
>
> That way will be easier to write, much easier to modify and almost certainly
> faster that a RE solution - and it can easily give you all the information
> in the file thus future proofing it.

Generally, even a recursive descent parser will be overkill. It's
pretty easy to do simple string manipulation to get the info you want;
maybe that means restricting the syntax some, but for a personal-use
script, that's usually no big cost. The example I gave requires that
the indentation be correct, and on this mailing list, I think people
agree that that's not a deal-breaker :)

ChrisA



More information about the Python-list mailing list