別のキーワード
ライブラリ
- ビルトイン (597)
- bigdecimal (36)
- json (12)
- optparse (144)
-
ripper
/ lexer (24) - stringio (48)
- strscan (120)
クラス
- Array (21)
- BasicObject (12)
- BigDecimal (36)
- Binding (7)
- IO (20)
- Integer (60)
- Method (12)
- Module (12)
- Object (60)
- OptionParser (144)
- Proc (12)
- Regexp (24)
-
Ripper
:: Lexer (24) - String (309)
- StringIO (48)
- StringScanner (120)
- Struct (24)
- UnboundMethod (24)
モジュール
キーワード
- % (12)
- << (9)
- =~ (24)
- [] (12)
- []= (12)
-
_ _ id _ _ (12) - arity (12)
- byteindex (3)
- byterindex (3)
- bytes (24)
- bytesize (12)
- charpos (12)
- chr (36)
- class (12)
- codepoints (24)
- concat (18)
-
const
_ source _ location (12) - count (12)
- exist? (12)
- getbyte (24)
- hash (24)
- hex (12)
- index (12)
- inspect (12)
- length (12)
- lex (12)
- match? (12)
-
matched
_ size (12) - method (12)
-
named
_ captures (12) - oct (12)
- on (144)
- ord (24)
- pack (21)
- parse (12)
- pointer (12)
- pos (12)
-
public
_ method (12) - pwrite (8)
- readbyte (12)
-
rest
_ size (12) - restsize (12)
- rindex (12)
- setbyte (12)
-
singleton
_ class (12) - size (12)
- skip (12)
-
skip
_ until (12) -
source
_ location (43) - split (12)
- sum (12)
- syswrite (12)
-
to
_ f (12) -
to
_ i (12) -
to
_ json (12) -
to
_ s (36) - truncate (12)
- unpack (12)
- write (12)
検索結果
先頭5件
-
String
# byterindex(pattern , offset = self . bytesize) -> Integer | nil (27568.0) -
文字列のバイト単位のインデックス offset から左に向かって pattern を探索します。 最初に見つかった部分文字列の左端のバイト単位のインデックスを返します。 見つからなければ nil を返します。
...イト単位のインデックス offset から左に向かって pattern を探索します。
最初に見つかった部分文字列の左端のバイト単位のインデックスを返します。
見つからなければ nil を返します。
引数 pattern は探索する部分文字列ま......たは正規表現で指定します。
offset が負の場合は、文字列の末尾から数えた位置から探索します。
byterindex と String#byteindex とでは、探索方向だけが逆になります。
完全に左右が反転した動作をするわけではありません。
探......//emlist[String#byteindex の場合][ruby]{
p "stringstring".byteindex("ing", 1) # => 3
# ing # ここから探索を始める
# ing
# ing # 右にずらしていってここで見つかる
//}
//emlist[String#byterindex の場合][ruby]{
p "stringstring".byterindex... -
String
# byteindex(pattern , offset = 0) -> Integer | nil (27426.0) -
文字列の offset から右に向かって pattern を検索し、 最初に見つかった部分文字列の左端のバイト単位のインデックスを返します。 見つからなければ nil を返します。
...文字列の offset から右に向かって pattern を検索し、
最初に見つかった部分文字列の左端のバイト単位のインデックスを返します。
見つからなければ nil を返します。
引数 pattern は探索する部分文字列または正規表現で指定......します。
offset が負の場合、文字列の末尾から数えた位置から探索します。
@param pattern 探索する部分文字列または正規表現
@param offset 探索を開始するバイト単位のオフセット
@raise IndexError オフセットが文字列の境界......emlist[例][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'.byteinde... -
String
# bytes -> [Integer] (27350.0) -
文字列の各バイトを数値の配列で返します。(self.each_byte.to_a と同じです)
..._byte.to_a と同じです)
//emlist[例][ruby]{
"str".bytes # => [115, 116, 114]
//}
ブロックが指定された場合は String#each_byte と同じように動作します。
Ruby 2.6 までは deprecated の警告が出ますが、Ruby 2.7 で警告は削除されました。
@see String#e......ach_byte... -
String
# bytesize -> Integer (27320.0) -
文字列のバイト長を整数で返します。
...文字列のバイト長を整数で返します。
//emlist[例][ruby]{
#coding:UTF-8
# 実行結果は文字コードによって異なります。
p "いろは".size #=> 3
p "いろは".bytesize #=> 9
//}
@see String#size... -
String
# to _ i(base = 10) -> Integer (27286.0) -
文字列を 10 進数表現された整数であると解釈して、整数に変換します。
...ist[例][ruby]{
p " 10".to_i # => 10
p "+10".to_i # => 10
p "-10".to_i # => -10
p "010".to_i # => 10
p "-010".to_i # => -10
//}
整数とみなせない文字があればそこまでを変換対象とします。
変換対象が空文字列であれば 0 を返します。
//emlist[......例][ruby]{
p "0x11".to_i # => 0
p "".to_i # => 0
//}
基数を指定することでデフォルトの 10 進以外に 2 〜 36 進数表現へ変換できます。
それぞれ Ruby の整数リテラルで使用可能なプリフィクスは無視されます。
また、base に 0 を指......gumentError が発生します。
//emlist[例][ruby]{
p "01".to_i(2) # => 1
p "0b1".to_i(2) # => 1
p "07".to_i(8) # => 7
p "0o7".to_i(8) # => 7
p "1f".to_i(16) # => 31
p "0x1f".to_i(16) # => 31
p "0b10".to_i(0) # => 2
p "0o10".to_i(0) # => 8
p "010".to_i(0) # => 8
p "0d10".to_i(... -
String
# oct -> Integer (27274.0) -
文字列を 8 進文字列であると解釈して、整数に変換します。
...//emlist[例][ruby]{
p "10".oct # => 8
p "010".oct # => 8
p "8".oct # => 0
//}
oct は文字列の接頭辞 ("0", "0b", "0B", "0x", "0X") に応じて
8 進以外の変換も行います。
//emlist[例][ruby]{
p "0b10".oct # => 2
p "10".oct # => 8
p "010".oct # => 8
p "0x10".oct # => 1......//emlist[例][ruby]{
p "-010".oct # => -8
p "-0x10".oct # => -16
p "-0b10".oct # => -2
p "1_0_1x".oct # => 65
//}
@see String#hex, String#to_i, String#to_f,
Kernel.#Integer, Kernel.#Float
逆に、数値を文字列に変換するにはKernel.#sprintf,
String#%, Integer#to_s を... -
String
# bytes {|byte| . . . } -> self (27250.0) -
文字列の各バイトを数値の配列で返します。(self.each_byte.to_a と同じです)
..._byte.to_a と同じです)
//emlist[例][ruby]{
"str".bytes # => [115, 116, 114]
//}
ブロックが指定された場合は String#each_byte と同じように動作します。
Ruby 2.6 までは deprecated の警告が出ますが、Ruby 2.7 で警告は削除されました。
@see String#e......ach_byte... -
String
# codepoints -> [Integer] (27250.0) -
文字列の各コードポイントの配列を返します。(self.each_codepoint.to_a と同じです)
...odepoint.to_a と同じです)
//emlist[例][ruby]{
#coding:UTF-8
"hello わーるど".codepoints
# => [104, 101, 108, 108, 111, 32, 12431, 12540, 12427, 12393]
//}
ブロックが指定された場合は String#each_codepoint と同じように動作します。
Ruby 2.6 までは deprecated の......警告が出ますが、Ruby 2.7 で警告は削除されました。
@see String#each_codepoint... -
String
# length -> Integer (27221.0) -
文字列の文字数を返します。バイト数を知りたいときは bytesize メソッドを使ってください。
...いときは bytesize メソッドを使ってください。
//emlist[例][ruby]{
"test".length # => 4
"test".size # => 4
"テスト".length # => 3
"テスト".size # => 3
"\x80\u3042".length # => 2
"\x80\u3042".size # => 2
//}
@see String#bytesize... -
Integer
# inspect(base=10) -> String (27215.0) -
整数を 10 進文字列表現に変換します。
...列表
現に変換します。
//emlist[][ruby]{
p 10.to_s(2) # => "1010"
p 10.to_s(8) # => "12"
p 10.to_s(16) # => "a"
p 35.to_s(36) # => "z"
//}
@return 数値の文字列表現
@param base 基数となる 2 - 36 の数値。
@raise ArgumentError base に 2 - 36 以外の数値を...