mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* lib/jcode.rb (String::tr_s): should have translated non
squeezing character sequence (i.e. a character) as well. thanks to Hiroshi Ichikawa <gimite at gimite.ddo.jp> [ruby-list:42090] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@10108 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
870eb33e6b
commit
a115742968
2 changed files with 7 additions and 1 deletions
|
@ -175,7 +175,7 @@ class String
|
|||
def tr_s!(from, to)
|
||||
return self.delete!(from) if to.length == 0
|
||||
|
||||
pattern = SqueezePatternCache[from] ||= /([#{_regex_quote(from)}])\1+/
|
||||
pattern = SqueezePatternCache[from] ||= /([#{_regex_quote(from)}])\1*/
|
||||
if from[0] == ?^
|
||||
last = /.$/.match(to)[0]
|
||||
self.gsub!(pattern, last)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue