* [ruby-core:49360] [Backport93 - Backport #7354][Open] String#gsub not working as expected
@ 2012-11-15 6:14 moonr0ck (Ilya Ostrovskiy)
2012-11-15 6:24 ` [ruby-core:49361] [Backport93 - Backport #7354] " moonr0ck (Ilya Ostrovskiy)
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: moonr0ck (Ilya Ostrovskiy) @ 2012-11-15 6:14 UTC (permalink / raw
To: ruby-core
Issue #7354 has been reported by moonr0ck (Ilya Ostrovskiy).
----------------------------------------
Backport #7354: String#gsub not working as expected
https://bugs.ruby-lang.org/issues/7354
Author: moonr0ck (Ilya Ostrovskiy)
Status: Open
Priority: Normal
Assignee:
Category:
Target version:
=begin
Windows 7, with Ruby 1.9.3p327, originally found in 1.9.3.p194
irb(main):001:0> filename = "test.txt"
=> "test.txt"
irb(main):002:0> suffix = "-suffix"
=> "-suffix"
irb(main):003:0> filename.gsub(/^(.+)(\..+)$/, "#{$1}#{suffix}#{$2}")
=> "-suffix"
irb(main):004:0> # ^ that doesn't look right
irb(main):005:0* # now if i add some spaces to the replacement string
irb(main):006:0* # it will work like it should (with the spaces)
irb(main):007:0* filename.gsub(/^(.+)(\..+)$/, "#{$1}#{suffix} #{$2}")
=> "test-suffix .txt"
irb(main):008:0> # and if i run the original it will work fine now
irb(main):009:0* filename.gsub(/^(.+)(\..+)$/, "#{$1}#{suffix}#{$2}")
=> "test-suffix.txt"
irb(main):010:0> # Running Windows 7, installed using RubyInstaller.org
irb(main):011:0* "#{RUBY_VERSION}p#{RUBY_PATCHLEVEL} (#{RUBY_RELEASE_DATE})"
=> "1.9.3p327 (2012-11-10)"
Arch Linux with Ruby 1.9.3.p286
irb(main):001:0> filename = "test.txt"
=> "test.txt"
irb(main):002:0> suffix = "-suffix"
=> "-suffix"
irb(main):003:0> filename.gsub(/^(.+)(\..+)$/, "#{$1}#{suffix}#{$2}")
=> "-suffix"
irb(main):004:0> # ^ that's not right
irb(main):005:0* # adding spaces works just like in windows
irb(main):006:0* filename.gsub(/^(.+)(\..+)$/, "#{$1}#{suffix} #{$2}")
=> "test-suffix .txt"
irb(main):007:0> # and removing the space gives the expected result now
irb(main):008:0* filename.gsub(/^(.+)(\..+)$/, "#{$1}#{suffix}#{$2}")
=> "test-suffix.txt"
irb(main):009:0> # Reproduced on Arch Linux
irb(main):010:0* "#{RUBY_VERSION}p#{RUBY_PATCHLEVEL} (#{RUBY_RELEASE_DATE})"
=> "1.9.3p286 (2012-10-12)"
=end
--
http://bugs.ruby-lang.org/
^ permalink raw reply [flat|nested] 4+ messages in thread
* [ruby-core:49361] [Backport93 - Backport #7354] String#gsub not working as expected
2012-11-15 6:14 [ruby-core:49360] [Backport93 - Backport #7354][Open] String#gsub not working as expected moonr0ck (Ilya Ostrovskiy)
@ 2012-11-15 6:24 ` moonr0ck (Ilya Ostrovskiy)
2012-11-15 6:28 ` [ruby-core:49362] [Backport93 - Backport #7354][Rejected] " naruse (Yui NARUSE)
2012-11-15 6:43 ` [ruby-core:49363] [Backport93 - Backport #7354] " moonr0ck (Ilya Ostrovskiy)
2 siblings, 0 replies; 4+ messages in thread
From: moonr0ck (Ilya Ostrovskiy) @ 2012-11-15 6:24 UTC (permalink / raw
To: ruby-core
Issue #7354 has been updated by moonr0ck (Ilya Ostrovskiy).
It appears the spaces have no effect, and simply re-running the gsub is sufficient to get the expected result.
irb(main):001:0> filename = "test.txt"
=> "test.txt"
irb(main):002:0> suffix = "-suffix"
=> "-suffix"
irb(main):003:0> filename.gsub(/^(.+)(\..+)$/, "#{$1}#{suffix}#{$2}")
=> "-suffix"
irb(main):004:0> filename.gsub(/^(.+)(\..+)$/, "#{$1}#{suffix}#{$2}")
=> "test-suffix.txt"
----------------------------------------
Backport #7354: String#gsub not working as expected
https://bugs.ruby-lang.org/issues/7354#change-32918
Author: moonr0ck (Ilya Ostrovskiy)
Status: Open
Priority: Normal
Assignee:
Category:
Target version:
=begin
Windows 7, with Ruby 1.9.3p327, originally found in 1.9.3.p194
irb(main):001:0> filename = "test.txt"
=> "test.txt"
irb(main):002:0> suffix = "-suffix"
=> "-suffix"
irb(main):003:0> filename.gsub(/^(.+)(\..+)$/, "#{$1}#{suffix}#{$2}")
=> "-suffix"
irb(main):004:0> # ^ that doesn't look right
irb(main):005:0* # now if i add some spaces to the replacement string
irb(main):006:0* # it will work like it should (with the spaces)
irb(main):007:0* filename.gsub(/^(.+)(\..+)$/, "#{$1}#{suffix} #{$2}")
=> "test-suffix .txt"
irb(main):008:0> # and if i run the original it will work fine now
irb(main):009:0* filename.gsub(/^(.+)(\..+)$/, "#{$1}#{suffix}#{$2}")
=> "test-suffix.txt"
irb(main):010:0> # Running Windows 7, installed using RubyInstaller.org
irb(main):011:0* "#{RUBY_VERSION}p#{RUBY_PATCHLEVEL} (#{RUBY_RELEASE_DATE})"
=> "1.9.3p327 (2012-11-10)"
Arch Linux with Ruby 1.9.3.p286
irb(main):001:0> filename = "test.txt"
=> "test.txt"
irb(main):002:0> suffix = "-suffix"
=> "-suffix"
irb(main):003:0> filename.gsub(/^(.+)(\..+)$/, "#{$1}#{suffix}#{$2}")
=> "-suffix"
irb(main):004:0> # ^ that's not right
irb(main):005:0* # adding spaces works just like in windows
irb(main):006:0* filename.gsub(/^(.+)(\..+)$/, "#{$1}#{suffix} #{$2}")
=> "test-suffix .txt"
irb(main):007:0> # and removing the space gives the expected result now
irb(main):008:0* filename.gsub(/^(.+)(\..+)$/, "#{$1}#{suffix}#{$2}")
=> "test-suffix.txt"
irb(main):009:0> # Reproduced on Arch Linux
irb(main):010:0* "#{RUBY_VERSION}p#{RUBY_PATCHLEVEL} (#{RUBY_RELEASE_DATE})"
=> "1.9.3p286 (2012-10-12)"
=end
--
http://bugs.ruby-lang.org/
^ permalink raw reply [flat|nested] 4+ messages in thread
* [ruby-core:49362] [Backport93 - Backport #7354][Rejected] String#gsub not working as expected
2012-11-15 6:14 [ruby-core:49360] [Backport93 - Backport #7354][Open] String#gsub not working as expected moonr0ck (Ilya Ostrovskiy)
2012-11-15 6:24 ` [ruby-core:49361] [Backport93 - Backport #7354] " moonr0ck (Ilya Ostrovskiy)
@ 2012-11-15 6:28 ` naruse (Yui NARUSE)
2012-11-15 6:43 ` [ruby-core:49363] [Backport93 - Backport #7354] " moonr0ck (Ilya Ostrovskiy)
2 siblings, 0 replies; 4+ messages in thread
From: naruse (Yui NARUSE) @ 2012-11-15 6:28 UTC (permalink / raw
To: ruby-core
Issue #7354 has been updated by naruse (Yui NARUSE).
Status changed from Open to Rejected
Embeded $1 is evaled before gsub runs.
You should write it as
filename.gsub(/^(.+)(\..+)$/){"#{$1}#{suffix}#{$2}"}
or
filename.gsub(/^(.+)(\..+)$/, "\\1#{suffix}\\2")
----------------------------------------
Backport #7354: String#gsub not working as expected
https://bugs.ruby-lang.org/issues/7354#change-32919
Author: moonr0ck (Ilya Ostrovskiy)
Status: Rejected
Priority: Normal
Assignee:
Category:
Target version:
=begin
Windows 7, with Ruby 1.9.3p327, originally found in 1.9.3.p194
irb(main):001:0> filename = "test.txt"
=> "test.txt"
irb(main):002:0> suffix = "-suffix"
=> "-suffix"
irb(main):003:0> filename.gsub(/^(.+)(\..+)$/, "#{$1}#{suffix}#{$2}")
=> "-suffix"
irb(main):004:0> # ^ that doesn't look right
irb(main):005:0* # now if i add some spaces to the replacement string
irb(main):006:0* # it will work like it should (with the spaces)
irb(main):007:0* filename.gsub(/^(.+)(\..+)$/, "#{$1}#{suffix} #{$2}")
=> "test-suffix .txt"
irb(main):008:0> # and if i run the original it will work fine now
irb(main):009:0* filename.gsub(/^(.+)(\..+)$/, "#{$1}#{suffix}#{$2}")
=> "test-suffix.txt"
irb(main):010:0> # Running Windows 7, installed using RubyInstaller.org
irb(main):011:0* "#{RUBY_VERSION}p#{RUBY_PATCHLEVEL} (#{RUBY_RELEASE_DATE})"
=> "1.9.3p327 (2012-11-10)"
Arch Linux with Ruby 1.9.3.p286
irb(main):001:0> filename = "test.txt"
=> "test.txt"
irb(main):002:0> suffix = "-suffix"
=> "-suffix"
irb(main):003:0> filename.gsub(/^(.+)(\..+)$/, "#{$1}#{suffix}#{$2}")
=> "-suffix"
irb(main):004:0> # ^ that's not right
irb(main):005:0* # adding spaces works just like in windows
irb(main):006:0* filename.gsub(/^(.+)(\..+)$/, "#{$1}#{suffix} #{$2}")
=> "test-suffix .txt"
irb(main):007:0> # and removing the space gives the expected result now
irb(main):008:0* filename.gsub(/^(.+)(\..+)$/, "#{$1}#{suffix}#{$2}")
=> "test-suffix.txt"
irb(main):009:0> # Reproduced on Arch Linux
irb(main):010:0* "#{RUBY_VERSION}p#{RUBY_PATCHLEVEL} (#{RUBY_RELEASE_DATE})"
=> "1.9.3p286 (2012-10-12)"
=end
--
http://bugs.ruby-lang.org/
^ permalink raw reply [flat|nested] 4+ messages in thread
* [ruby-core:49363] [Backport93 - Backport #7354] String#gsub not working as expected
2012-11-15 6:14 [ruby-core:49360] [Backport93 - Backport #7354][Open] String#gsub not working as expected moonr0ck (Ilya Ostrovskiy)
2012-11-15 6:24 ` [ruby-core:49361] [Backport93 - Backport #7354] " moonr0ck (Ilya Ostrovskiy)
2012-11-15 6:28 ` [ruby-core:49362] [Backport93 - Backport #7354][Rejected] " naruse (Yui NARUSE)
@ 2012-11-15 6:43 ` moonr0ck (Ilya Ostrovskiy)
2 siblings, 0 replies; 4+ messages in thread
From: moonr0ck (Ilya Ostrovskiy) @ 2012-11-15 6:43 UTC (permalink / raw
To: ruby-core
Issue #7354 has been updated by moonr0ck (Ilya Ostrovskiy).
Thank you! :) I had a feeling that perhaps it wasn't a bug and I was just doing something wrong.
----------------------------------------
Backport #7354: String#gsub not working as expected
https://bugs.ruby-lang.org/issues/7354#change-32920
Author: moonr0ck (Ilya Ostrovskiy)
Status: Rejected
Priority: Normal
Assignee:
Category:
Target version:
=begin
Windows 7, with Ruby 1.9.3p327, originally found in 1.9.3.p194
irb(main):001:0> filename = "test.txt"
=> "test.txt"
irb(main):002:0> suffix = "-suffix"
=> "-suffix"
irb(main):003:0> filename.gsub(/^(.+)(\..+)$/, "#{$1}#{suffix}#{$2}")
=> "-suffix"
irb(main):004:0> # ^ that doesn't look right
irb(main):005:0* # now if i add some spaces to the replacement string
irb(main):006:0* # it will work like it should (with the spaces)
irb(main):007:0* filename.gsub(/^(.+)(\..+)$/, "#{$1}#{suffix} #{$2}")
=> "test-suffix .txt"
irb(main):008:0> # and if i run the original it will work fine now
irb(main):009:0* filename.gsub(/^(.+)(\..+)$/, "#{$1}#{suffix}#{$2}")
=> "test-suffix.txt"
irb(main):010:0> # Running Windows 7, installed using RubyInstaller.org
irb(main):011:0* "#{RUBY_VERSION}p#{RUBY_PATCHLEVEL} (#{RUBY_RELEASE_DATE})"
=> "1.9.3p327 (2012-11-10)"
Arch Linux with Ruby 1.9.3.p286
irb(main):001:0> filename = "test.txt"
=> "test.txt"
irb(main):002:0> suffix = "-suffix"
=> "-suffix"
irb(main):003:0> filename.gsub(/^(.+)(\..+)$/, "#{$1}#{suffix}#{$2}")
=> "-suffix"
irb(main):004:0> # ^ that's not right
irb(main):005:0* # adding spaces works just like in windows
irb(main):006:0* filename.gsub(/^(.+)(\..+)$/, "#{$1}#{suffix} #{$2}")
=> "test-suffix .txt"
irb(main):007:0> # and removing the space gives the expected result now
irb(main):008:0* filename.gsub(/^(.+)(\..+)$/, "#{$1}#{suffix}#{$2}")
=> "test-suffix.txt"
irb(main):009:0> # Reproduced on Arch Linux
irb(main):010:0* "#{RUBY_VERSION}p#{RUBY_PATCHLEVEL} (#{RUBY_RELEASE_DATE})"
=> "1.9.3p286 (2012-10-12)"
=end
--
http://bugs.ruby-lang.org/
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2012-11-15 6:42 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-11-15 6:14 [ruby-core:49360] [Backport93 - Backport #7354][Open] String#gsub not working as expected moonr0ck (Ilya Ostrovskiy)
2012-11-15 6:24 ` [ruby-core:49361] [Backport93 - Backport #7354] " moonr0ck (Ilya Ostrovskiy)
2012-11-15 6:28 ` [ruby-core:49362] [Backport93 - Backport #7354][Rejected] " naruse (Yui NARUSE)
2012-11-15 6:43 ` [ruby-core:49363] [Backport93 - Backport #7354] " moonr0ck (Ilya Ostrovskiy)
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).