having recently migrated one of my machines from a 1.6 flavor to the
new 1.8 i must say i was surprised to see problems with
blah.gsub!(“testing”, ’ ')
i got a message that it was going to ignore(?) this statement as
"testing" was not a regexp… this hit me on more than one script,
forcing me into a quick-fix mode as i definitely was not anticipating
this script-debilitating “ignore” of my code…
i don’t understand the need to nitpick the regexp in this case, if
someone passes a string it seems quite a simple task for you to ENSURE BACKWARDS COMPATIBILITY and convert it internally to a regexp
This is a deprecation warning. It will no longer be backwards compatible in
1.9 and later, IIRC (maybe as early as 1.8.1).
In 1.8.0, however, it’s just a warning.
-austin
···
On Thu, 18 Dec 2003 11:01:56 +0900, Joseph Benik wrote:
i don’t understand the need to nitpick the regexp in this case, if
someone passes a string it seems quite a simple task for you to ENSURE
BACKWARDS COMPATIBILITY and convert it internally to a regexp
blah.gsub!(“testing”, ’ ')
i got a message that it was going to ignore(?) this statement as
“testing” was not a regexp… this hit me on more than one script,
forcing me into a quick-fix mode as i definitely was not anticipating
this script-debilitating “ignore” of my code…
Your statement won’t be ignored, there will just be that warning. Why?
Because “…bar”.gsub(“.”, “foo”) produces “foofoofoobar” and not
“foofoofoofoofoofoo”. This wasn’t always this way – in Ruby 1.6.8
Strings were handled just like Regexps in this case. I myself really
prefer the current behaviour to the old one because the old one is still
available (use /#{foo}/) and this allows you to easily substitute user
input without using the longish Regexp.escape() which would be forgotten
way to often and thus cause security risks anyway.
The warning will go away in 1.9.0, AFAIK. I’d suggest either using
/#{Regexp.escape(foo)}/ or disabling the warnings via the
-W0-command-line-option or $-w = nil for now.
I had this “problem”, too. I can’t see why Ruby is so verbose on that
and doesn’t interpret foo.gsub[!](“bar”, …) as foo.gsub[!](/bar/, …)
automagically…
Regards,
···
On Thu, Dec 18, 2003 at 12:39:53PM +0900, Austin Ziegler wrote:
On Thu, 18 Dec 2003 11:01:56 +0900, Joseph Benik wrote:
i don’t understand the need to nitpick the regexp in this case, if
someone passes a string it seems quite a simple task for you to ENSURE
BACKWARDS COMPATIBILITY and convert it internally to a regexp
This is a deprecation warning. It will no longer be backwards compatible in
1.9 and later, IIRC (maybe as early as 1.8.1).
In 1.8.0, however, it’s just a warning.
–
University of Athens I bet the human brain
Physics Department is a kludge --Marvin Minsky
this word is the reason for many, many, many hours spent debugging perl
scripts. if you have done much perl programming you will know exactly what i
mean.
i’m all for backward compatibility - unless the ‘old’ way wasn’t all that good.
IMHO, it wasn’t all that good to be able to do this (same situation as gsub)
why doesn’t this work, after all my string does start with an ‘a’?
On Thu, Dec 18, 2003 at 12:39:53PM +0900, Austin Ziegler wrote:
On Thu, 18 Dec 2003 11:01:56 +0900, Joseph Benik wrote:
i don’t understand the need to nitpick the regexp in this case, if
someone passes a string it seems quite a simple task for you to ENSURE
BACKWARDS COMPATIBILITY and convert it internally to a regexp
This is a deprecation warning. It will no longer be backwards compatible in
1.9 and later, IIRC (maybe as early as 1.8.1).
In 1.8.0, however, it’s just a warning.
I had this “problem”, too. I can’t see why Ruby is so verbose on that
and doesn’t interpret foo.gsub[!](“bar”, …) as foo.gsub[!](/bar/, …)
automagically…
–
ATTN: please update your address books with address below!
The difference between art and science is that science is what we
understand well enough to explain to a computer.
Art is everything else.
– Donald Knuth, “Discover”
/bin/sh -c ‘for l in ruby perl;do $l -e “print "\x3a\x2d\x29\x0a"”;done’
===============================================================================
I had this “problem”, too. I can’t see why Ruby is so verbose on that
and doesn’t interpret foo.gsub[!](“bar”, …) as foo.gsub[!](/bar/, …)
automagically…
works, though a touch less elegant. No biggie, though. Perhaps there’s a
better way than that?
Jim
···
On Fri, 19 Dec 2003 03:12:57 +0900 Elias Athanasopoulos elathan@phys.uoa.gr wrote:
I had this “problem”, too. I can’t see why Ruby is so verbose on that
and doesn’t interpret foo.gsub[!](“bar”, …) as foo.gsub[!](/bar/, …)
automagically…
I had this “problem”, too. I can’t see why Ruby is so verbose on that
and doesn’t interpret foo.gsub[!](“bar”, …) as foo.gsub[!](/bar/, …)
automagically…
Well, for one, I think more people would expect it to be interpreted as
foo.gsub(Regexp.quote(bar), …)
I had this “problem”, too. I can’t see why Ruby is so verbose on that
and doesn’t interpret foo.gsub[!](“bar”, …) as foo.gsub[!](/bar/, …)
automagically…
Well, for one, I think more people would expect it to be interpreted as
foo.gsub(Regexp.quote(bar), …)