re quiz

John Machin sjmachin at lexicon.net
Thu Jun 12 14:12:55 CEST 2008


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." -- care to tell us what "a certain re.sub" is, and
false in what way?



More information about the Python-list mailing list