Re: Why isn't SPLIT splitting my strings

2006-11-19 Thread John Henry
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("[; ()\[\]"

Re: Why isn't SPLIT splitting my strings

2006-11-19 Thread Fredrik Lundh
John Henry wrote: > Oops! for cases like this, writing "[" + re.escape(charset) + "]" 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.er

Re: Why isn't SPLIT splitting my strings

2006-11-19 Thread John Henry
Oops! newString= re.split("[; ()\[\]", result) John Henry wrote: > Meaning: > > import re > > newString= re.split('[; ()\[\]", result) > > > > Nick Vatamaniuc wrote: > > The regular string split does not take a _class_ of characters as the > > separator, it only takes one separator. Your example

Re: Why isn't SPLIT splitting my strings

2006-11-19 Thread John Henry
Meaning: import re newString= re.split('[; ()\[\]", result) Nick Vatamaniuc wrote: > The regular string split does not take a _class_ of characters as the > separator, it only takes one separator. Your example suggests that you > expect that _any_ of the characters "; ()[]" could be a separato

Re: Why isn't SPLIT splitting my strings

2006-11-19 Thread Paul McGuire
"ronrsr" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > I'm trying to break up the result tuple into keyword phrases. The > keyword phrases are separated by a ; -- the split function is not > working the way I believe it should be. Can anyone see what I"m doing > wrong? > > bests,

Re: Why isn't SPLIT splitting my strings

2006-11-19 Thread Duncan Booth
"ronrsr" <[EMAIL PROTECTED]> wrote: > I'm trying to break up the result tuple into keyword phrases. The > keyword phrases are separated by a ; -- the split function is not > working the way I believe it should be. Can anyone see what I"m doing > wrong? I think your example boils down to: >>> h

Re: Why isn't SPLIT splitting my strings

2006-11-19 Thread Fredrik Lundh
ronrsr wrote: > I'm trying to break up the result tuple into keyword phrases. The > keyword phrases are separated by a ; -- the split function is not > working the way I believe it should be. >>> help(str.split) split(...) S.split([sep [,maxsplit]]) -> list of strings Return a lis

Re: Why isn't SPLIT splitting my strings

2006-11-19 Thread Nick Vatamaniuc
The regular string split does not take a _class_ of characters as the separator, it only takes one separator. Your example suggests that you expect that _any_ of the characters "; ()[]" could be a separator. If you want to use a regular expression as a list of separators, then you need to use the s