As far as I know there is no such switch.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?
If you can't convert your string in, say, lowercase, before splitting, you may have to use the re module:
In [1]: test = 'A big Fat CAt'
In [2]: import re
In [3]: A=re.compile('a', re.IGNORECASE)
In [4]: A.split(test) Out[4]: ['', ' big F', 't C', 't']
['', ' big Fat C', 't']test = 'A big Fat CAt' A = test.split('A') print Aa = [] for x in xrange(len(A)):... tmp = A[x].split('a') ... for y in xrange(len(tmp)): ... a.append(tmp[y]) ...['', ' big F', 't C', 't']a
As a side note, reduce is great in such situations:
In [5]: reduce(list.__add__,[t.split('a') for t in test.split('A')],[]) Out[5]: ['', ' big F', 't C', 't'] -- http://mail.python.org/mailman/listinfo/python-list