I think from reading
http://www.opensource.apple.com/darwinso... that it's
Regexp::MULTILINE to change the behaviour of '.', and
Regexp::SINGLELINE to change the behaviour of '^' and '$', but I
don't believe the comments about REOPTIONPOSIXLINE because
that's not what /s does in Perl. He's right that this should be
better documented though!
Of course the author's wrong. They say "In other languages, the
multiline flag is off by default, and when enabled, it considers .
to include newlines and ^ and $ to match right after, and right
before, every newline."
In Perl, /m only changes '^' and '$'. /s changes '.'. You can
combine them to get the same effect as described above: /ms (or
/sm). I therefore presume that Python's re.MULTILINE is equivalent
to /ms, which means none of us are using consistent concepts.
actually (dislaimer: regexps make my eyes bleed) http://docs.python.org/lib/node46.html
says MULTILINE is equivalent to /m, DOTALL changes the '.'
behaviour. So perl /m is python M, perl /s is python S - looks like
it matches across those two, at least.
I'd say his sum-up there is confused, if I'm reading it right -
Ruby's behaviour is not expected (perl and python both use
multiline to affect ^$, and dotall to affect ., whereas ruby uses
multiline to affect . and singleline to affect ^$), but his
description of other language behaviour is slightly skew-whiff. I
think ;)
6 comments so far
That's a pretty scathing sum-up - be interested to see the responses it gets
4 months ago by silarsis.
I think from reading http://www.opensource.apple.com/darwinso... that it's Regexp::MULTILINE to change the behaviour of '.', and Regexp::SINGLELINE to change the behaviour of '^' and '$', but I don't believe the comments about REOPTIONPOSIXLINE because that's not what /s does in Perl. He's right that this should be better documented though!
4 months ago by jarich.
Of course the author's wrong. They say "In other languages, the multiline flag is off by default, and when enabled, it considers . to include newlines and ^ and $ to match right after, and right before, every newline."
In Perl, /m only changes '^' and '$'. /s changes '.'. You can combine them to get the same effect as described above: /ms (or /sm). I therefore presume that Python's re.MULTILINE is equivalent to /ms, which means none of us are using consistent concepts.
4 months ago by jarich.
actually (dislaimer: regexps make my eyes bleed) http://docs.python.org/lib/node46.html says MULTILINE is equivalent to /m, DOTALL changes the '.' behaviour. So perl /m is python M, perl /s is python S - looks like it matches across those two, at least.
4 months ago by silarsis.
I'd say his sum-up there is confused, if I'm reading it right - Ruby's behaviour is not expected (perl and python both use multiline to affect ^$, and dotall to affect ., whereas ruby uses multiline to affect . and singleline to affect ^$), but his description of other language behaviour is slightly skew-whiff. I think ;)
4 months ago by silarsis.
I think you're right. I'm not versed enough in Ruby to comment on most of the rest of it though.
4 months ago by jarich.