Regex driving me crazy...

Grant Edwards invalid at invalid.invalid
Wed Apr 7 17:47:23 EDT 2010


On 2010-04-07, J <dreadpiratejeff at gmail.com> wrote:

> Can someone make me un-crazy?

Definitely.  Regex is driving you crazy, so don't use a regex.

  inputString = "# 1  Short offline       Completed without error     00%       679         -"
  
  print ' '.join(inputString.split()[4:-3])

> So any ideas on what the best way to proceed with this would be?

Anytime you have a problem with a regex, the first thing you should
ask yourself:  "do I really, _really_ need a regex?

Hint: the answer is usually "no".

-- 
Grant Edwards               grant.b.edwards        Yow! I'm continually AMAZED
                                  at               at th'breathtaking effects
                              gmail.com            of WIND EROSION!!



More information about the Python-list mailing list