[Tutor] reading parts of a input string into different variables based on units.
Alan Gauld
alan.gauld at btinternet.com
Thu Mar 20 10:33:38 CET 2008
"Kent Johnson" <kent37 at tds.net> wrote
> One regex can split apart a numeric part and a non-numeric unit:
> In [24]: splitter.findall('2m 4cm 3mm')
> Out[24]: [('2', 'm'), ('4', 'cm'), ('3', 'mm')]
As ever Kent, a neat solution. Much more efficient than
my 3 way search and relatively easy to split the list
apart for analysis.
Even the regex is cleaner! :-)
Alan G.
More information about the Tutor
mailing list