P
Pavel Smerk
Hello,
in Perl I have \Q and \E in regexps allowing me to "literally" insert
variable containing special characters:
$ perl -e '$a=".*"; print "a"=~/$a/ || 0, "a"=~/\Q$a\E/ || 0, "\n"'
10
$
i.e., for nonperlists, if I have '.*' string in the variable $a, then
/$a/ is the same as /.*/ (and as such matches 'a'), but /\Q$a\E/ equals
/\.\*/ (and thus does not match 'a'), because all special characters are
treated as preceded by backslash.
Is there something like that in Ruby?
Anyway, why Ruby does not take over whole perl5 RE? Especially
look-behind assertions and \L, \l like special characters?
Thanks,
P.
in Perl I have \Q and \E in regexps allowing me to "literally" insert
variable containing special characters:
$ perl -e '$a=".*"; print "a"=~/$a/ || 0, "a"=~/\Q$a\E/ || 0, "\n"'
10
$
i.e., for nonperlists, if I have '.*' string in the variable $a, then
/$a/ is the same as /.*/ (and as such matches 'a'), but /\Q$a\E/ equals
/\.\*/ (and thus does not match 'a'), because all special characters are
treated as preceded by backslash.
Is there something like that in Ruby?
Anyway, why Ruby does not take over whole perl5 RE? Especially
look-behind assertions and \L, \l like special characters?
Thanks,
P.