るりまサーチ

最速Rubyリファレンスマニュアル検索!
2077件ヒット [1901-2000件を表示] (0.144秒)

別のキーワード

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

ライブラリ

キーワード

検索結果

<< < ... 18 19 20 21 > >>

String#unpack1(format) -> object (30026.0)

formatにしたがって文字列をデコードし、展開された1つ目の値を返します。 unpackは配列を返しますがunpack1は配列の1つ目の要素のみを返します。

...って文字列をデコードし、展開された1つ目の値を返します。
unpackは配列を返しますがunpack1は配列の1つ目の要素のみを返します。

//emlist[例][ruby]{
"ABC".unpack1("C*") # => 65
"ABC".unpack("C*") # => [65, 66, 67]
//}

@
see String#unpack, Array#pack...

String#scan(pattern) {|s| ... } -> self (30020.0)

pattern がマッチした部分文字列をブロックに渡して実行します。 pattern が正規表現で括弧を含む場合は、 括弧で括られたパターンにマッチした文字列の配列を渡します。

...す。
pattern が正規表現で括弧を含む場合は、
括弧で括られたパターンにマッチした文字列の配列を渡します。

@
param pattern 探索する部分文字列または正規表現

//emlist[例][ruby]{
"foobarbazfoobarbaz".scan(/ba./) {|s| p s }
# "bar"
# "baz"
# "b...

String#concat(*arguments) -> self (30018.0)

self に複数の文字列を破壊的に連結します。

...に相当する文字を末尾に追加します。追加する文字のエンコーディングは self.encoding です。

self を返します。

@
param arguments 複数の文字列もしくは 0 以上の整数

//emlist[例][ruby]{
str = "foo"
str.concat
p str # => "foo"

str = "foo"
str.co...

String#count(*chars) -> Integer (30014.0)

chars で指定された文字が文字列 self にいくつあるか数えます。

...) によりエスケープできます。

引数を複数指定した場合は、
すべての引数にマッチした文字だけを数えます。

@
param chars 出現回数を数える文字のパターン

//emlist[例][ruby]{
p 'abcdefg'.count('c') # => 1
p '123456789'.count('...

String#encoding -> Encoding (30014.0)

文字列のエンコーディング情報を表現した Encoding オブジェクトを返します。

...列のエンコーディング情報を表現した Encoding オブジェクトを返します。

//emlist[例][ruby]{
# encoding: utf-8
utf8_str = "test"
euc_str = utf8_str.encode("EUC-JP")
utf8_str.encoding # => #<Encoding:UTF-8>
euc_str.encoding # => #<Encoding:EUC-JP>
//}

@
see Encoding...

絞り込み条件を変える

String#force_encoding(encoding) -> self (30014.0)

文字列の持つエンコーディング情報を指定された encoding に変えます。

...されず、検査もされません。
Array#pack などで得られたバイト列のエンコーディングを指定する時に使います。

@
param encoding 変更するエンコーディング情報を表す文字列か Encoding オブジェクトを指定します。

//emlist[例][ruby]...

String#getbyte(index) -> Integer | nil (30014.0)

index バイト目のバイトを整数で返します。

...dex に負を指定すると末尾から数えた位置のバイト
を取り出します。
範囲外を指定した場合は nil を返します。

@
param index バイトを取り出す位置

//emlist[例][ruby]{
s = "tester"
s.bytes # => [116, 101, 115, 116, 101, 114]
s.getbyte(0)...

String#hash -> Integer (30014.0)

self のハッシュ値を返します。 eql? で等しい文字列は、常にハッシュ値も等しくなります。

...self のハッシュ値を返します。
eql? で等しい文字列は、常にハッシュ値も等しくなります。

//emlist[例][ruby]{
"test".hash # => 4038258770210371295
("te" + "st").hash == "test".hash # => true
//}

@
see Hash...

String#include?(substr) -> bool (30014.0)

文字列中に部分文字列 substr が含まれていれば真を返します。

...文字列中に部分文字列 substr が含まれていれば真を返します。

@
param substr 検索する文字列

//emlist[例][ruby]{
"hello".include? "lo" #=> true
"hello".include? "ol" #=> false
"hello".include? ?h #=> true
//}...

String#match(regexp, pos = 0) -> MatchData | nil (30014.0)

regexp.match(self, pos) と同じです。 regexp が文字列の場合は、正規表現にコンパイルします。 詳しくは Regexp#match を参照してください。

...('h.ge', 1) # => #<MatchData "hige">
//}

//emlist[例: ブロックを指定した場合][ruby]{
'hello'.match('(.)\1'){|e|"match #{$1}"} # => "match l"
'hello'.match('xx'){|e|"match #{$1}"} # マッチしないためブロックは実行されない
//}

@
see Regexp#match, Symbol#match...
...h('h.ge', 1) # => #<MatchData "hige">
//}

//emlist[例: ブロックを指定した場合][ruby]{
'hello'.match('(.)\1'){|e|"match #{$1}"} # => "match l"
'hello'.match('xx'){|e|"match #{$1}"} # マッチしないためブロックは実行されない
//}

@
see Regexp#match, Symbol#match...

絞り込み条件を変える

<< < ... 18 19 20 21 > >>