No subject

Jaime Wyant programmer.py at gmail.com
Sat Apr 16 18:47:39 EDT 2005


You need to look at the re module.
     
>>> import re
>>> dir(re)
>>> re.split('A|a', 'A big Fat CAt')
['', ' big F', 't C', 't']

Then google around for a regular expression tutorial...

jw


On 4/16/05, Michael.Coll-Barth at verizonwireless.com
<Michael.Coll-Barth at verizonwireless.com> 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?
> 
> >>> 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']
> 
> It is odd about the help files, after I figure out how to do something, the
> help makes sense.  Before hand is another story...  Are there any others out
> there that share this misery?
> 
> thanks,
> Michael
> ___________________________________________________________________
> The information contained in this message and any attachment may be
> proprietary, confidential, and privileged or subject to the work
> product doctrine and thus protected from disclosure.  If the reader
> of this message is not the intended recipient, or an employee or
> agent responsible for delivering this message to the intended
> recipient, you are hereby notified that any dissemination,
> distribution or copying of this communication is strictly prohibited.
> If you have received this communication in error, please notify me
> immediately by replying to this message and deleting it and all
> copies and backups thereof.  Thank you.
> 
> --
> http://mail.python.org/mailman/listinfo/python-list
>



More information about the Python-list mailing list