re quiz

David C. Ullrich dullrich at sprynet.com
Thu Jun 12 10:11:05 EDT 2008


On Thu, 12 Jun 2008 05:12:55 -0700 (PDT), John Machin
<sjmachin at lexicon.net> wrote:

>On Jun 12, 8:57 pm, David C. Ullrich <dullr... at sprynet.com> wrote:
>> True or False? (no fair looking it up)
>>
>> (*) If repl is a string then re.sub(pattern, repl, s)
>> returns s with non-overlapping occurences of pattern
>> replaced by repl.
>>
>> I assumed it was true - spent a few hours trying to
>> figure out what was going on with a certain re.sub,
>> then noticed that (*) is false:
>>
>
>Well, the docs do say "Return the string obtained by replacing the
>leftmost non-overlapping occurrences of pattern in string by the
>replacement repl."

That's the _first sentence_, yes. I _quoted_ another sentence
(from an old version, istr it phrased slightly differently in
recent versions) in my post.

> -- care to tell us what "a certain re.sub" is, and
>false in what way?

Read the OP.
David C. Ullrich



More information about the Python-list mailing list