[Tutor] using regular expressions

Magnus Lyckå magnus@thinkware.se
Tue Jul 8 17:40:03 2003


At 23:01 2003-07-08 +0200, Karl Pflästerer wrote:
>In python you can compile your regexp.  That gives faster results.  Then
>it is often better to use a `try ...except' block instead of `if ...' if
>you do the search in a loop.

Actually, I think that twenty (?) regular expressions are cached
automagically in Python, so you don't need to compile them to
increase performance, but it looks better not to repeat that
string I think.

>    'Twas brillig, and the slithy toves
>         Did gyre and gimble in the wabe;
>     All mimsy were the borogoves,
>          And the mome raths outgrabe.   "Lewis Carroll" "Jabberwocky"

      'En slidig ödling borvlade
          I bryningen på solvis ples.
      Och lumpingen var brynklig, och
          Den villa grutten fnes.         "Gösta Knutsson" "Jabberwocky"


--
Magnus Lycka (It's really Lyckå), magnus@thinkware.se
Thinkware AB, Sweden, www.thinkware.se
I code Python ~ The Agile Programming Language