[BangPypers] Parse multi line with re module.

Gora Mohanty gora at mimirtech.com
Tue Jan 3 16:23:59 CET 2012

On Tue, Jan 3, 2012 at 8:31 PM, Pratap Chakravarthy <prataprc at gmail.com> wrote:
>> Mean no offence to you personally,
> None taken.

Thank you for taking things in a good spirit: Personally speaking,
I discover almost each day how ignorant I am compared to other
people, in many contexts. True knowledge should be the progressive
discovery of one's ignorance.

>                    I believe Ganesh might take your more specific regex and
> use that with findall() grouping to get what he wants. It is always a
> good practice to be more specific in composing regular expressions,
> carelessly composed PCRE (where P stands for Perl ;) ) regex can lead
> to exponential complexity for simple inputs.

Um, that "exponential complexity" is *exactly* the problem.

Regular expressions are extremely powerful, and can and
maybe should be used in the right context. I presume that
everyone has read Jamie Zawinski's rants about regular

I wish that I could find again the story of someone, whose boss
barely looked at his regular expression that spanned half-a-screen,
and said that "you have a bug". The (obviously talented)
developer spent over a day finding edge-cases, and went back
to his boss, and said: "You are right, but please tell me how
you could tell at a glance". Boss' answer was that he did not
actually know that there was a bug, but the use of a regular
expression of that size pretty much assured him that there
would be one.

As someone said in another context (about C++), when
regular expressions are your only tool, every problem
looks like your thumb.

>> but this thread should again be a reason why regular
>> expressions should be used sparingly, if at all,
>> and against well-validated input.
> Really ?
> I beg to differ.

*Really?* I believe that the ball is currently in your court.
It was *your* regex that was broken, and badly, if I may


More information about the BangPypers mailing list