On Sun, June 1, 2008 4:58 pm, Kent Johnson wrote:

> On Sun, Jun 1, 2008 at 2:04 PM, Marilyn Davis <[EMAIL PROTECTED]>
> wrote:
>
>> On Sun, June 1, 2008 10:30 am, Alan Gauld wrote:
>>
>>
>>> "Kent Johnson" <[EMAIL PROTECTED]> wrote
>>>
>>>
>>>
>>>> Assuming the strings are non-overlapping, i.e. the closing "." of
>>>> one string is not the opening "." of another, you can find them all
>>>> with import re re.findall(r'\..*?\.', text)
>>>
>>> Hmm, my regex hopelessness comes to the fore again.
>>> Why a *?
>>> I would probably have guessed the pattern to be
>>>
>>>
>>>
>>> \..+?\.
>>>
>
> Mine will find two adjacent periods with no intervening text, yours
> won't. Whether this makes any difference to the OP, or which is correct, I
> don't know.

Yeh, we need a better spec. I was wondering if the stuff between the text
ought not include white space, or even a word boundary.  A character class
might be better, if we knew.

Anyhow, I think we wore out the student. :^)

Marilyn Davis

>
>> This little program includes a function to test regular expressions.  I
>>  find it helpful and I give it to students.  I think such programs
>> exist on the net.
>
> I am always surprised at how many regex testers there are, because a
> simple tester comes with Python. It is called redemo.py; look for it in the
> Tools/scripts  or bin/ directory installed with Python. On my
> Mac it is at
> /Library/Frameworks/Python.framework/Versions/2.5/bin/redemo.py.
>
>
> Kent


_______________________________________________
Tutor maillist  -  [email protected]
http://mail.python.org/mailman/listinfo/tutor

Reply via email to