From: Waider (waider at domain waider.ie)
Date: Wed 11 Sep 2002 - 13:16:02 IST
-----BEGIN PGP SIGNED MESSAGE-----
Padraig Brady wrote:
|
| What I have in python now is:
| fields = re.split('[ ]+|"([^"]*)"', record)
| And this is OK except there are empty and
| null fields returned. I'm sure there is
| a more elegant re to acheive this?
|
Here's the canonical Perl solution:
http://www.perldoc.com/perl5.6/faq/perlfaq4.html#How-can-I-split-a-%5bcharacter%5d-delimited-string-except-when-inside%0a%5bcharacter%5d--(Comma-separated-files)
Personally, when faced with this sort of task, I just break it down
rather than trying to accomplish it in a single clever step. Usually I
get the code written faster.
Cheers,
Waider.
- --
waider at domain waider.ie / Yes, it /is/ very personal of me
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.0.6 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org
iQEVAwUBPX8z8aHbXyzZsAb3AQF3kAgAxUQqYio9D/DaA+vsZq64pDfw9+HZx/8E
5ZAzS7ZRMivXPFjhVlmb9Kw9GTc7ldCFsslVjnxaXX3XzkhxTQmpggHrMQnlbHrK
rK98LBGECKZ0wnZZhjhzfH8XOxfh26DiPRjXJCq5k7U3k4tWzbenqmRpOcUKj/ed
ryWHpzQDe9pzucc6Ba6KkfBRYSGeWFR1m7uqzaP9WkuvpkOmRSjK/ZvdGuZPPcUx
ocmL2cGPVxcbis2BZt0XcBy8C0t7q0iPD9aClrvMDSFk9YqSS32l27yGS1DFO7Iy
7880A4S8ud55k57VRR6H0gya9uhoGNYqdMWGT2ZeVVDwQKEUrY5KkQ==
=LsVG
-----END PGP SIGNATURE-----
This archive was generated by hypermail 2.1.6 : Thu 06 Feb 2003 - 13:18:48 GMT