How do I parse this ? regexp ?
Jorge Godoy
godoy at ieee.org
Wed Apr 27 11:01:53 EDT 2005
"serpent17 at gmail.com" <serpent17 at gmail.com> writes:
> Hello all,
>
> I have this line of numbers:
>
>
> 04242005 18:20:42-0.000002, 271.1748608, [-4.119873046875,
> 3.4332275390625, 105.062255859375], [0.093780517578125, 0.041015625,
> -0.960662841796875], [0.01556396484375, 0.01220703125,
> 0.01068115234375]
>
>
> repeated several times in a text file and I would like each element to
> be part of a vector. how do I do this ? I am not very capable in using
> regexp as you can see.
You don't need a regexp to do that.
Use the split string method. It will split on spaces by default. If you want
to keep the values inside "[]" together, remove the spaces before splitting or
split on the "[" char first and then split the first item using spaces as a
separator.
Be seeing you,
--
Jorge Godoy <godoy at ieee.org>
More information about the Python-list
mailing list