[Tutor] Regular Expression Misunderstanding
Steve Nelson
sanelson at gmail.com
Fri Jul 14 15:24:06 CEST 2006
On 7/14/06, Kent Johnson <kent37 at tds.net> wrote:
> But for this particular application you might as well use
> line.startswith('b') instead of a regex.
Ah yes, that makes sense.
Incidentally continuing my reading of the HOWTO I have sat and puzzled
for about 30 mins on the difference the MULTILINE flag makes. I can't
quite see the difference. I *think* it is as follows:
Under normal circumstances, ^ matches the start of a line, only. On a
line by line basis.
With the re.M flag, we get a match after *any* newline?
Similarly with $ - under normal circumstances, $ matches the end of
the string, or that which precedes a newline.
With the MULTILINE flag, $ matches before *any* newline?
Is this correct?
> Kent
S.
More information about the Tutor
mailing list