Actions
Backport #3747
closedPossible bug of String#count?
Status:
Closed
Assignee:
Description
=begin
$ ruby -v
ruby 1.9.1p429 (2010-07-02 revision 28523) [i386-darwin9]
$ cat c.rb
-- coding: utf-8 --¶
s = "a\u3042" # \u3042 is the japanese hiragana "a"
puts s.encoding.name
puts s.count("^a")
$ ruby c.rb
UTF-8
0
The result of count method should be 1 but is 0.
=end
Updated by darix (Marcus Rückert) over 13 years ago
=begin
didnt you want to say:
$ puts s.count("a")
1
if you do:
$ s = "^a\u3042"
$ puts s.count("^a")
1
=end
Updated by lirh (Ruohao Li) over 13 years ago
=begin
In the documentation of String#count, "Any other_str that starts with a
caret (^) is negated". Thus s.count("^a") means the number of characters
that is not a, which should be 1.
=end
Updated by shyouhei (Shyouhei Urabe) over 13 years ago
- Status changed from Open to Assigned
- Assignee set to naruse (Yui NARUSE)
=begin
=end
Updated by naruse (Yui NARUSE) over 13 years ago
- Status changed from Assigned to Closed
- % Done changed from 0 to 100
=begin
This issue was solved with changeset r29146.
Ruohao, thank you for reporting this issue.
Your contribution to Ruby is greatly appreciated.
May Ruby be with you.
=end
Updated by naruse (Yui NARUSE) over 13 years ago
- Assignee changed from naruse (Yui NARUSE) to yugui (Yuki Sonoda)
=begin
=end
Actions
Like0
Like0Like0Like0Like0Like0