るりまサーチ

最速Rubyリファレンスマニュアル検索!
2561件ヒット [1-100件を表示] (0.045秒)

別のキーワード

  1. string []=
  2. string slice
  3. string slice!
  4. string []
  5. string gsub!

ライブラリ

モジュール

キーワード

検索結果

<< 1 2 3 ... > >>

String#size -> Integer (24125.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...

StringIO#size -> Integer (18101.0)

文字列の長さを返します。

文字列の長さを返します。

Symbol#size -> Integer (15119.0)

シンボルに対応する文字列の長さを返します。

...シンボルに対応する文字列の長さを返します。

(self.to_s.length と同じです。)

:foo.length #=> 3

@see String#length, String#size...

String#bytesize -> Integer (15118.0)

文字列のバイト長を整数で返します。

...文字列のバイト長を整数で返します。

//emlist[例][ruby]{
#coding:UTF-8
# 実行結果は文字コードによって異なります。
p "いろは".size #=> 3
p "いろは".bytesize #=> 9
//}

@see String#size...

String.new(string = "", encoding: string.encoding, capacity: string.bytesize) -> String (9579.0)

string と同じ内容の新しい文字列を作成して返します。 引数を省略した場合は空文字列を生成して返します。

...
string
と同じ内容の新しい文字列を作成して返します。
引数を省略した場合は空文字列を生成して返します。

@param string 文字列
@param encoding 作成する文字列のエンコーディングを文字列か
Encoding オブジェクト...
...で指定します(変換は行われま
せん)。省略した場合は引数 string のエンコーディングと同
じになります(ただし、string が指定されていなかった場合は
Encoding::ASCII_8BITになります)。
@param capa...
...合、引数stringのバイト数が127未満であれば127、
それ以上であればstring.bytesizeになります。
@return 引数 string と同じ内容の文字列オブジェクト

//emlist[例][ruby]{
text = "hoge".encode("EUC-JP")
no_option = String.new(text)...

絞り込み条件を変える

StringScanner#rest_size -> Integer (9141.0)

文字列の残りの長さを返します。 stringscanner.rest.size と同じです。

...す。
string
scanner.rest.size と同じです。

String
Scanner#restsize は将来のバージョンで削除される予定です。
代わりにStringScanner#rest_size を使ってください。

//emlist[例][ruby]{
require 'strscan'

s = StringScanner.new('test string')
p s.rest_size # => 11
p...
...s.rest.size # => 11
//}...

StringScanner#restsize -> Integer (9141.0)

文字列の残りの長さを返します。 stringscanner.rest.size と同じです。

...す。
string
scanner.rest.size と同じです。

String
Scanner#restsize は将来のバージョンで削除される予定です。
代わりにStringScanner#rest_size を使ってください。

//emlist[例][ruby]{
require 'strscan'

s = StringScanner.new('test string')
p s.rest_size # => 11
p...
...s.rest.size # => 11
//}...

String#[](nth) -> String | nil (9134.0)

nth 番目の文字を返します。 nth が負の場合は文字列の末尾から数えます。 つまり、 self.size + nth 番目の文字を返します。

...の末尾から数えます。
つまり、 self.size + nth 番目の文字を返します。

nth が範囲外を指す場合は nil を返します。

@param nth 文字の位置を表す整数
@return 指定した位置の文字を表す String オブジェクト

//emlist[例][ruby]{
p 'bar'[2]...

String#slice(nth) -> String | nil (9134.0)

nth 番目の文字を返します。 nth が負の場合は文字列の末尾から数えます。 つまり、 self.size + nth 番目の文字を返します。

...の末尾から数えます。
つまり、 self.size + nth 番目の文字を返します。

nth が範囲外を指す場合は nil を返します。

@param nth 文字の位置を表す整数
@return 指定した位置の文字を表す String オブジェクト

//emlist[例][ruby]{
p 'bar'[2]...
<< 1 2 3 ... > >>