On Dec 14, 2006, at 12:52 PM, Mark T. wrote:
OK, so we have
Ruby /\Axyz\z/ is the same as Perl /^xyz$/,
Ruby /^xyz$/ is the same as Perl /^xyz$/m,
Ruby /^xyz$/m is the same as Perl /^xyz$/ms,
is this correct?
I think you’ve got it. Here are some examples of perl and ruby with
some similar regexps to demonstrate.
$ perl -e ‘$string = “uvw\nxyz\nABC”; if ($string =~ /^xyz$/) { print
“match\n” } else { print “nope\n” }’
nope
$ ruby -e ‘string = “uvw\nxyz\nABC”; if (string =~ /\Axyz\z/) then
print “match\n” else print “nope\n” end’
nope
$ perl -e ‘$string = “uvw\nxyz\nABC”; if ($string =~ /^xyz$/m)
{ print “match\n” } else { print “nope\n” }’
match
$ ruby -e ‘string = “uvw\nxyz\nABC”; if (string =~ /^xyz$/) then
print “match\n” else print “nope\n” end’
match
$ perl -e ‘$string = “uvw\nxyz\nABC”; if ($string =~ /^xyz…$/m)
{ print “match\n” } else { print “nope\n” }’
nope
$ perl -e ‘$string = “uvw\nxyz\nABC”; if ($string =~ /^xyz…$/ms)
{ print “match\n” } else { print “nope\n” }’
match
$ ruby -e ‘string = “uvw\nxyz\nABC”; if (string =~ /^xyz…$/m) then
print “match\n” else print “nope\n” end’
match
$ ruby -e ‘string = “uvw\nxyz\nABC”; if (string =~ /^xyz…\z/m)
then print “match\n” else print “nope\n” end’
match
$ ruby -e ‘string = “uvw\nxyz\nABC”; if (string =~ /\A…xyz…\z/
m) then print “match\n” else print “nope\n” end’
match
$ ruby -e ‘string = “uvw\nxyz\nABC”; if (string =~ /\A…xyz…\z/)
then print “match\n” else print “nope\n” end’
nope
$ ruby -e ‘string = “uvw\nxyz\nABC”; if (string =~ /^xyz…\z/) then
print “match\n” else print “nope\n” end’
nope
Rob B. http://agileconsultingllc.com
[email protected]