mirror of
https://github.com/ruby/ruby.git
synced 2026-01-26 12:14:51 +00:00
[DOC] Japanese for multi-byte characters
This commit is contained in:
parent
44e762a99c
commit
d615dbf4e2
Notes:
git
2025-12-28 20:51:37 +00:00
Merged: https://github.com/ruby/ruby/pull/15752 Merged-By: peterzhu2118 <peter@peterzhu.ca>
@ -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:
|
||||
|
||||
@ -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:
|
||||
|
||||
@ -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:
|
||||
|
||||
@ -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:
|
||||
|
||||
@ -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:
|
||||
|
||||
@ -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:
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user