別のキーワード
キーワード
- % (12)
- + (12)
- == (12)
- === (12)
- [] (72)
- []= (12)
- byteindex (3)
- byterindex (3)
- bytes (24)
- bytesize (12)
- byteslice (36)
- casecmp? (9)
- chars (12)
- codepoints (12)
- dump (12)
-
each
_ byte (24) -
each
_ char (12) -
each
_ codepoint (12) -
each
_ grapheme _ cluster (8) - empty? (12)
- encode (36)
-
end
_ with? (12) - eql? (12)
- getbyte (12)
-
grapheme
_ clusters (8) - gsub (48)
- gsub! (48)
- include? (12)
- intern (12)
- iseuc (12)
- match (12)
- match? (9)
- next (12)
- next! (12)
- oct (12)
- scan (24)
- scrub (36)
- scrub! (36)
- setbyte (12)
- slice (72)
- slice! (12)
- split (19)
-
start
_ with? (12) - sub (36)
- sub! (36)
- succ (12)
- succ! (12)
- sum (12)
-
to
_ i (12) -
to
_ sym (12) -
unicode
_ normalized? (11) - unpack (12)
- unpack1 (9)
- upto (12)
-
valid
_ encoding? (12)
検索結果
先頭5件
-
String
# gsub(pattern) {|matched| . . . . } -> String (6136.0) -
文字列中で pattern にマッチした部分を順番にブロックに渡し、 その実行結果で置き換えた文字列を生成して返します。 ブロックなしの場合と違い、ブロックの中からは 組み込み変数 $1, $2, $3, ... を問題なく参照できます。
...表現。
文字列を指定した場合は全く同じ文字列にだけマッチする
@return 新しい文字列
//emlist[例][ruby]{
p 'abcabc'.gsub(/[bc]/) {|s| s.upcase } #=> "aBCaBC"
p 'abcabc'.gsub(/[bc]/) { $&.upcase } #=> "aBCaBC"
//}
@see String#sub, String#scan... -
String
# sub!(pattern) {|matched| . . . . } -> self | nil (6136.0) -
文字列中で pattern にマッチした最初の部分をブロックに渡し、 その評価結果へ破壊的に置き換えます。
...にマッチした最初の部分をブロックに渡し、
その評価結果へ破壊的に置き換えます。
また、ブロックなしの sub と違い、ブロックの中からは
組み込み変数 $1, $2, $3, ... を問題なく参照できます。
@param pattern 置き換える......は全く同じ文字列にだけマッチする
@return 置換した場合は self、置換しなかった場合は nil
//emlist[例][ruby]{
str = 'abcabc'
str.sub!(/b/) {|s| s.upcase }
p str #=> "aBcabc"
str = 'abcabc'
str.sub!(/b/) { $&.upcase }
p str #=> "aBcabc"
//}
@see String#gsub... -
String
# byteslice(nth) -> String | nil (6118.0) -
nth バイト目の文字を返します。nth が負の場合は文字列の末尾から数えます。 引数が範囲外を指定した場合は nil を返します。
...rn 切り出した文字列を返します。戻り値の文字エンコーディングは自身
と同じです。
//emlist[例][ruby]{
"hello".byteslice(1) # => "e"
"hello".byteslice(-1) # => "o"
"\u3042".byteslice(0) # => "\xE3"
"\u3042".byteslice(1) # => "\x81"
//}
@see String#slice... -
String
# byteslice(nth , len=1) -> String | nil (6118.0) -
nth バイト目から長さ len バイトの部分文字列を新しく作って返します。 nth が負の場合は文字列の末尾から数えます。引数が範囲外を指定した場合は nil を返します。
...数で指定します。
@return 切り出した文字列を返します。戻り値の文字エンコーディングは自身
と同じです。
//emlist[例][ruby]{
"hello".byteslice(1, 2) # => "el"
"\u3042\u3044\u3046".byteslice(0, 3) # => "\u3042"
//}
@see String#slice......。
@return 切り出した文字列を返します。戻り値の文字エンコーディングは自身
と同じです。
//emlist[例][ruby]{
"hello".byteslice(1, 2) # => "el"
"\u3042\u3044\u3046".byteslice(0, 3) # => "\u3042"
//}
@see String#slice
@see String#bytesplice... -
String
# byteslice(range) -> String | nil (6118.0) -
range で指定したバイトの範囲に含まれる部分文字列を返します。引数が範囲 外を指定した場合は nil を返します。
...を示す Range オブジェクト
@return 切り出した文字列を返します。戻り値の文字エンコーディングは自身
と同じです。
//emlist[例][ruby]{
"hello".byteslice(1..2) # => "el"
"\x03\u3042\xff".byteslice(1..3) # => "\u3042"
//}
@see String#slice......ェクト
@return 切り出した文字列を返します。戻り値の文字エンコーディングは自身
と同じです。
//emlist[例][ruby]{
"hello".byteslice(1..2) # => "el"
"\x03\u3042\xff".byteslice(1..3) # => "\u3042"
//}
@see String#slice
@see String#bytesplice... -
String
# sub!(pattern , hash) -> String (6116.0) -
文字列中の pattern にマッチした部分をキーにして hash を引いた値で破壊的に置き換えます。
文字列中の pattern にマッチした部分をキーにして hash を引いた値で破壊的に置き換えます。
@param pattern 置き換える文字列のパターン
@param hash 置き換える文字列を与えるハッシュ
@return 置換した場合は self、置換しなかった場合は nil -
String
# byteindex(pattern , offset = 0) -> Integer | nil (6114.0) -
文字列の offset から右に向かって pattern を検索し、 最初に見つかった部分文字列の左端のバイト単位のインデックスを返します。 見つからなければ nil を返します。
...list[例][ruby]{
'foo'.byteindex('f') # => 0
'foo'.byteindex('o') # => 1
'foo'.byteindex('oo') # => 1
'foo'.byteindex('ooo') # => nil
'foo'.byteindex(/f/) # => 0
'foo'.byteindex(/o/) # => 1
'foo'.byteindex(/oo/) # => 1
'foo'.byteindex(/ooo/) # => nil
'foo'.byteindex('o', 1) # => 1
'foo'.byteindex(......'foo'.byteindex('o', 3) # => nil
'foo'.byteindex('o', -1) # => 2
'foo'.byteindex('o', -2) # => 1
'foo'.byteindex('o', -3) # => 1
'foo'.byteindex('o', -4) # => nil
'あいう'.byteindex('う') # => 6
'あいう'.byteindex('う', 3) # => 6
'あいう'.byteindex('う', -3) # => 6
'あいう'.byteind......ex('う', 1) # offset 1 does not land on character boundary (IndexError)
//}
@see String#index, String#byterindex... -
String
# bytesize -> Integer (6114.0) -
文字列のバイト長を整数で返します。
...文字列のバイト長を整数で返します。
//emlist[例][ruby]{
#coding:UTF-8
# 実行結果は文字コードによって異なります。
p "いろは".size #=> 3
p "いろは".bytesize #=> 9
//}
@see String#size... -
String
# each _ byte -> Enumerator (6114.0) -
文字列の各バイトに対して繰り返します。
...文字列の各バイトに対して繰り返します。
//emlist[例][ruby]{
"str".each_byte do |byte|
p byte
end
# => 115
# => 116
# => 114
"あ".each_byte do |byte|
p byte
end
# => 227
# => 129
# => 130
//}
@see String#bytes... -
String
# getbyte(index) -> Integer | nil (6114.0) -
index バイト目のバイトを整数で返します。
...定した場合は nil を返します。
@param index バイトを取り出す位置
//emlist[例][ruby]{
s = "tester"
s.bytes # => [116, 101, 115, 116, 101, 114]
s.getbyte(0) # => 116
s.getbyte(1) # => 101
s.getbyte(-1) # => 114
s.getbyte(6) # => nil
//}...