[EMAIL PROTECTED] wrote:
All,
I have been going through the manuals and not having much luck with the
following code. This is basically an issue of giving 'split' multiple
patterns to split a string. If it had an ignore case switch, the problem
would be solved. Instead, I have to code the following, which works fine
for a single byte string. What can I do when I want to look for strings?
Use re.split() instead of str.split(). It uses any regex as the split
string:
>>> import re
>>> test = 'A big Fat CAt'
>>> re.split('[aA]', test)
['', ' big F', 't C', 't']
Kent
test = 'A big Fat CAt'
A = test.split('A')
print A
['', ' big Fat C', 't']
a = []
for x in xrange(len(A)):
... tmp = A[x].split('a')
... for y in xrange(len(tmp)):
... a.append(tmp[y])
...
a
['', ' big F', 't C', 't']
--
http://mail.python.org/mailman/listinfo/python-list