[DOC] Japanese for multi-byte characters

This commit is contained in:
Burdette Lamar 2025-12-28 14:51:10 -06:00 committed by GitHub
parent 44e762a99c
commit d615dbf4e2
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
Notes: git 2025-12-28 20:51:37 +00:00
Merged: https://github.com/ruby/ruby/pull/15752

Merged-By: peterzhu2118 <peter@peterzhu.ca>
6 changed files with 30 additions and 31 deletions

View File

@ -31,7 +31,6 @@ contained in the selector itself:
'abracadabra'.delete('abc') # => "rdr"
'0123456789'.delete('258') # => "0134679"
'!@#$%&*()_+'.delete('+&#') # => "!@$%*()_"
'тест'.delete('т') # => "ес"
'こんにちは'.delete('に') # => "こんちは"
Note that order and repetitions do not matter:

View File

@ -10,12 +10,12 @@ returns the offset of the beginning of the <tt>n</tt>th match:
m[3] # => "113"
m.begin(3) # => 3
m = /(т)(е)(с)/.match('тест')
# => #<MatchData "тес" 1:"т" 2:"е" 3:"с">
m[0] # => "тес"
m.begin(0) # => 0
m[3] # => "с"
m.begin(3) # => 2
m = /(ん)(に)(ち)/.match('こんにちは')
# => #<MatchData "んにち" 1:"ん" 2:"に" 3:"ち">
m[0] # => "んにち"
m.begin(0) # => 1
m[3] # => ""
m.begin(3) # => 3
When string or symbol argument +name+ is given,
returns the offset of the beginning for the named match:

View File

@ -10,12 +10,12 @@ returns the offset of the beginning of the <tt>n</tt>th match:
m[3] # => "113"
m.bytebegin(3) # => 3
m = /(т)(е)(с)/.match('тест')
# => #<MatchData "тес" 1:"т" 2:"е" 3:"с">
m[0] # => "тес"
m.bytebegin(0) # => 0
m[3] # => "с"
m.bytebegin(3) # => 4
m = /(ん)(に)(ち)/.match('こんにちは')
# => #<MatchData "んにち" 1:"ん" 2:"に" 3:"ち">
m[0] # => "んにち"
m.bytebegin(0) # => 3
m[3] # => "ち"
m.bytebegin(3) # => 9
When string or symbol argument +name+ is given,
returns the offset of the beginning for the named match:

View File

@ -10,12 +10,12 @@ returns the offset of the end of the <tt>n</tt>th match:
m[3] # => "113"
m.byteend(3) # => 6
m = /(т)(е)(с)/.match('тест')
# => #<MatchData "тес" 1:"т" 2:"е" 3:"с">
m[0] # => "тес"
m.byteend(0) # => 6
m[3] # => "с"
m.byteend(3) # => 6
m = /(ん)(に)(ち)/.match('こんにちは')
# => #<MatchData "んにち" 1:"ん" 2:"に" 3:"ち">
m[0] # => "んにち"
m.byteend(0) # => 12
m[3] # => "ち"
m.byteend(3) # => 12
When string or symbol argument +name+ is given,
returns the offset of the end for the named match:

View File

@ -10,12 +10,12 @@ returns the offset of the end of the <tt>n</tt>th match:
m[3] # => "113"
m.end(3) # => 6
m = /(т)(е)(с)/.match('тест')
# => #<MatchData "тес" 1:"т" 2:"е" 3:"с">
m[0] # => "тес"
m.end(0) # => 3
m[3] # => "с"
m.end(3) # => 3
m = /(ん)(に)(ち)/.match('こんにちは')
# => #<MatchData "んにち" 1:"ん" 2:"に" 3:"ち">
m[0] # => "んにち"
m.end(0) # => 4
m[3] # => ""
m.end(3) # => 4
When string or symbol argument +name+ is given,
returns the offset of the end for the named match:

View File

@ -11,12 +11,12 @@ returns the starting and ending offsets of the <tt>n</tt>th match:
m[3] # => "113"
m.offset(3) # => [3, 6]
m = /(т)(е)(с)/.match('тест')
# => #<MatchData "тес" 1:"т" 2:"е" 3:"с">
m[0] # => "тес"
m.offset(0) # => [0, 3]
m[3] # => "с"
m.offset(3) # => [2, 3]
m = /(ん)(に)(ち)/.match('こんにちは')
# => #<MatchData "んにち" 1:"ん" 2:"に" 3:"ち">
m[0] # => "んにち"
m.offset(0) # => [1, 4]
m[3] # => ""
m.offset(3) # => [3, 4]
When string or symbol argument +name+ is given,
returns the starting and ending offsets for the named match: