I'm using Python 2.7.0 and and doing the following in the interpreter:
>>> re.search (r"//\s*.*?$", "//\n\na12345678", flags=re.MULTILINE|re.DOTALL).group()
'//\n\na12345678'
This is not what I expected. I though $ would match before the endline, but it included the two endline characters AND text after that?
Surprisingly, this works:
>>> re.search (r"//\s*.*?$", "//1\n\na12345678", flags=re.MULTILINE|re.DOTALL).group()
'//1'
What am I misunderstanding here about python regular expressions?
Some more info:
>>> re.search(r"//\s*.*", "//\n test").group()
'//\n test'
>>> re.search(r"//\s*.*", "//1\n test").group()
'//1'
This last block of code is without MUTLILINE and DOTALL? What am I misunderstanding here? .* shouldn't be matching the newline, and definitely not go past it, right?