Why isn't SPLIT splitting my strings
John Henry
john106henry at hotmail.com
Sun Nov 19 12:38:04 EST 2006
Fredrik Lundh wrote:
> John Henry wrote:
>
> > Oops!
>
> for cases like this, writing
>
> "[" + re.escape(charset) + "]"
>
So, like this?
newString= re.split("[" + re.escape("; ()[]") + "]", result)
> is usually a good way to avoid repeated oops:ing.
>
> > newString= re.split("[; ()\[\]", result)
>
> >>> newString= re.split("[; ()\[\]", result)
> Traceback (most recent call last):
> ...
> sre_constants.error: unexpected end of regular expression
>
Strange. It works for me. Oh, I know, it's missing a "]".
newString= re.split("[; ()\[\]]", result)
> </F>
More information about the Python-list
mailing list