using string.splitfields

Fredrik Lundh fredrik at pythonware.com
Mon Oct 11 15:59:16 EDT 1999


Thomas Weholt <u970130 at studbo.hit.no> wrote:
> Just wondering how I could use more field-separators when I use the
> string.splitfield method.

you can't.  string.split can only
deal with a single separator.

(string.splitfield is obsolete, btw.
use string.split instead).

in this case, you can use
re.split instead:

import re
print re.split("[.+!]", "this.is+a!string")
## ['this', 'is', 'a', 'string']

</F>

coming soon:
http://www.pythonware.com/people/fredrik/librarybook.htm





More information about the Python-list mailing list