Re:



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@xxxxxxxxxxxxxxxxxxx
<Michael.Coll-Barth@xxxxxxxxxxxxxxxxxxx> 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
>
.



Relevant Pages

  • RE:
    ... patterns to split a string. ... It is odd about the help files, after I figure out how to do something, the ... distribution or copying of this communication is strictly prohibited. ...
    (comp.lang.python)
  • regular expression
    ... Make sure that the string is 20 chars or else match should fail. ... Any ideas on how this can be done using just one regular expression? ... This communication, including attachments, is ... If you are not the intended recipient, ...
    (perl.beginners)
  • RE: Newbie Question
    ... Subject: Newbie Question ... I have a file that contains many lines, each of which consists of a string ... distribution or copying of this communication is strictly prohibited. ...
    (comp.lang.python)
  • Re: call of ShellExecuteEx causes error message
    ... the lpParameters string of ShellExecuteInfo, but with socket communication. ... //define pix vector from Photoshop image ...
    (microsoft.public.win32.programmer.networks)
  • RE: Email fro FORM
    ... trust me i love to go through the help files and it always ... Simple string manip. ... Dim SendTo As String ...
    (microsoft.public.access.formscoding)