re.sub and re.MULTILINE

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • nyenyec

    #1

    re.sub and re.MULTILINE

    I feel like a complete idiot but I can't figure out why re.sub won't
    match multiline strings:

    This works:
    >>re.search("^f oo", "\nfoo", re.MULTILINE)
    <_sre.SRE_Mat ch object at 0x6c448>

    This doesn't. No replacement:
    >>re.sub("^foo" , "bar", "\nfoo", re.MULTILINE)
    '\nfoo'

    Why?

    Thanks,
    nyenyec

Working...