Regexp.MULTILINE

while we’re still on it, i wonder whose decision it is to remove perl’s
dual //s + //m modifiers and just adopt //s (that is, “.” will match a
newline) and treat ^ & $ line-wise regardless of the modifiers. was it
matz’s? i think this is a fine design decision, since many people have
trouble understanding //s and //m.

but i wonder why the chosen name is MULTILINE (//m) instead of
SINGLELINE (//s), and moreover why doesn’t ruby complain when i give an
s modifier. this has bitten me a couple of times in the past, since i
often use the s modifier in my perl regexes. i believe many perl
programmers were/will be bitten by this one.

···


dave

but i wonder why the chosen name is MULTILINE (//m) instead of
SINGLELINE (//s), and moreover why doesn't ruby complain when i give an

//s means SJIS encoding

ruby has support for multibyte sequences

Guy Decoux

Hi –

while we’re still on it, i wonder whose decision it is to remove perl’s
dual //s + //m modifiers and just adopt //s (that is, “.” will match a
newline) and treat ^ & $ line-wise regardless of the modifiers. was it
matz’s? i think this is a fine design decision, since many people have
trouble understanding //s and //m.

All Ruby decisions are matz’s, as far as I know :slight_smile: I like this one
too, especially in conjunction with \A, \Z, \z.

but i wonder why the chosen name is MULTILINE (//m) instead of
SINGLELINE (//s), and moreover why doesn’t ruby complain when i give an
s modifier. this has bitten me a couple of times in the past, since i
often use the s modifier in my perl regexes. i believe many perl
programmers were/will be bitten by this one.

Hmmm. I guess you could argue that making . include \n means that
matches more easily straddle multiple lines. Also, since $ and ^
always address the string line-wise, it’s sort of misleading to
describe it as treating the string as a single line.

(Slightly playing devil’s advocate, but anyway.)

David

···

On Mon, 7 Oct 2002, David Garamond wrote:


David Alan Black | Register for RubyConf 2002!
home: dblack@candle.superlink.net | November 1-3
work: blackdav@shu.edu | Seattle, WA, USA
Web: http://pirate.shu.edu/~blackdav | http://www.rubyconf.com

ts wrote:

“D” == David Garamond davegaramond@icqmail.com writes:

but i wonder why the chosen name is MULTILINE (//m) instead of
SINGLELINE (//s), and moreover why doesn’t ruby complain when i give an

//s means SJIS encoding

ruby has support for multibyte sequences

oh, sorry. i wasn’t reading the documentation carefully enough. but then
why does the lang parameter consume the lowercase and the uppercase
character as well? couldn’t SJIS encoding just given the parameter ‘S’
instead of ‘s’ and ‘S’?

···


dave

dblack@candle.superlink.net wrote:

Hmmm. I guess you could argue that making . include \n means that
matches more easily straddle multiple lines. Also, since $ and ^
always address the string line-wise, it’s sort of misleading to
describe it as treating the string as a single line.

well, “single line” or “multiple line” is just a matter of terminology.
but traditionally “single line” (s modifier) has meant ‘matching “\n”
for .’, so the ruby terminology “multiple line” is at odds with perl’s
re, pcre, python’s re, and perhaps most others too. i suspect (though
not blame) matz chose the “m” instead of “s” because he wanted “s” to
mean “SJIS” so it’s easier to remember for japanese people.

···


dave

Hi,

···

In message “Re: Regexp.MULTILINE” on 02/10/08, David Garamond davegaramond@icqmail.com writes:

well, “single line” or “multiple line” is just a matter of terminology.
but traditionally “single line” (s modifier) has meant ‘matching “\n”
for .’, so the ruby terminology “multiple line” is at odds with perl’s
re, pcre, python’s re, and perhaps most others too. i suspect (though
not blame) matz chose the “m” instead of “s” because he wanted “s” to
mean “SJIS” so it’s easier to remember for japanese people.

Agreed. Besides I felt Perl’s combination of /s and /m was insane.

						matz.