別のキーワード
キーワード
- % (12)
- * (12)
- + (12)
- +@ (10)
- -@ (10)
- << (12)
- <=> (12)
- == (12)
- === (12)
- =~ (12)
- [] (72)
- []= (84)
-
append
_ as _ bytes (1) - b (12)
- byterindex (3)
- bytes (24)
- capitalize! (12)
- casecmp (12)
- casecmp? (9)
- center (12)
- chars (24)
- chomp (12)
- chomp! (12)
- chop! (12)
- chr (12)
- clear (12)
- codepoints (24)
- concat (21)
- count (12)
- crypt (12)
- dedup (3)
- delete (12)
- delete! (12)
-
delete
_ prefix! (8) -
delete
_ suffix! (8) - downcase! (12)
-
each
_ byte (24) -
each
_ char (24) -
each
_ codepoint (24) -
each
_ grapheme _ cluster (16) -
each
_ line (24) - encode (36)
- encode! (24)
-
end
_ with? (12) -
force
_ encoding (12) -
grapheme
_ clusters (16) - gsub! (48)
- hash (12)
- hex (12)
- insert (12)
- iseuc (12)
- lines (24)
- ljust (12)
- lstrip! (12)
- match (24)
- match? (9)
- next (12)
- next! (12)
- ord (12)
-
parse
_ csv (12) - partition (12)
- replace (12)
- reverse! (12)
- rindex (12)
- rjust (12)
- rpartition (12)
- rstrip! (12)
- scan (24)
- scrub (36)
- scrub! (36)
- slice (72)
- split (14)
- squeeze! (12)
-
start
_ with? (12) - strip! (12)
- sub! (36)
- succ (12)
- succ! (12)
- swapcase! (12)
-
to
_ s (12) -
to
_ str (12) -
tr
_ s! (12) - undump (8)
-
unicode
_ normalize (11) -
unicode
_ normalize! (11) -
unicode
_ normalized? (11) - upcase! (12)
- upto (12)
検索結果
先頭5件
-
String
# []=(regexp , name , val) (25.0) -
正規表現 regexp の name で指定した名前付きキャプチャにマッチする最初の 部分文字列を文字列 val で置き換えます。
...置き換えたい文字列
@return val を返します。
@raise IndexError name で指定した名前付きキャプチャが存在しない場合に発
生します。
//emlist[例][ruby]{
s = "FooBar"
s[/(?<foo>[A-Z]..)(?<bar>[A-Z]..)/, "foo"] = "Baz"
p s # => "BazBar"
//}... -
String
# []=(regexp , nth , val) (25.0) -
正規表現 regexp の nth 番目の括弧にマッチする 最初の部分文字列を文字列 val で置き換えます。
...定範囲の部分文字列と置き換えたい文字列
@return val を返します。
@raise IndexError 正規表現がマッチしなかった場合に発生します。
//emlist[例][ruby]{
buf = "def exec(cmd)"
buf[/def\s+(\w+)/, 1] = "preprocess"
p buf # => "def preprocess(cmd)"
//}... -
String
# []=(regexp , val) (25.0) -
正規表現 regexp にマッチした部分文字列全体を val で置き換えます。
...い部分文字列のパターンを示す正規表現
@param val 置き換えたい文字列
@return val を返します。
@raise IndexError 正規表現がマッチしなかった場合に発生します。
//emlist[例][ruby]{
buf = "string"
buf[/tr../] = "!!"
p buf # => "s!!g"
//}... -
String
# *(times) -> String (20.0) -
文字列の内容を times 回だけ繰り返した新しい文字列を作成して返します。
...字列を作成して返します。
@param times 整数
@return self を times 回繰り返した新しい文字列
@raise ArgumentError 引数に負数を指定したときに発生します。
//emlist[例][ruby]{
p "str" * 3 # => "strstrstr"
str = "abc"
p str * 4 # => "abcabca... -
String
# +(other) -> String (20.0) -
文字列と other を連結した新しい文字列を返します。
...列と other を連結した新しい文字列を返します。
@param other 文字列
@return self と other を連結した文字列
//emlist[例][ruby]{
p "str" + "ing" # => "string"
a = "abc"
b = "def"
p a + b # => "abcdef"
p a # => "abc" (変化なし)
p b # => "... -
String
# ==(other) -> bool (20.0) -
other が文字列の場合、String#eql? と同様に文字列の内容を比較します。
...other が文字列の場合、String#eql? と同様に文字列の内容を比較します。
other が文字列でない場合、
other.to_str が定義されていれば
other == self の結果を返します。(ただし、 other.to_str は実行されません。)
そうでなければ false......st[例][ruby]{
stringlike = Object.new
def stringlike.==(other)
"string" == other
end
p "string".eql?(stringlike) #=> false
p "string" == stringlike #=> false
def stringlike.to_str
raise
end
p "string".eql?(stringlike) #=> false
p "string" == stringlike #=> true
//}
@see String#eql?... -
String
# ===(other) -> bool (20.0) -
other が文字列の場合、String#eql? と同様に文字列の内容を比較します。
...other が文字列の場合、String#eql? と同様に文字列の内容を比較します。
other が文字列でない場合、
other.to_str が定義されていれば
other == self の結果を返します。(ただし、 other.to_str は実行されません。)
そうでなければ false......st[例][ruby]{
stringlike = Object.new
def stringlike.==(other)
"string" == other
end
p "string".eql?(stringlike) #=> false
p "string" == stringlike #=> false
def stringlike.to_str
raise
end
p "string".eql?(stringlike) #=> false
p "string" == stringlike #=> true
//}
@see String#eql?... -
String
# =~(other) -> Integer | nil (20.0) -
正規表現 other とのマッチを行います。 マッチが成功すればマッチした位置のインデックスを、そうでなければ nil を返します。
...た位置のインデックスを、そうでなければ nil を返します。
other が正規表現でも文字列でもない場合は
other =~ self を行います。
このメソッドが実行されると、組み込み変数 $~, $1, ...
にマッチに関する情報が設定されます......。
@param other 正規表現もしくは =~ メソッドを持つオブジェクト
@raise TypeError other が文字列の場合に発生します。
//emlist[例][ruby]{
p "string" =~ /str/ # => 0
p "string" =~ /not/ # => nil
p "abcfoo" =~ /foo/ # => 3
//}... -
String
# hex -> Integer (20.0) -
文字列に 16 進数で数値が表現されていると解釈して整数に変換します。 接頭辞 "0x", "0X" とアンダースコアは無視されます。 文字列が [_0-9a-fA-F] 以外の文字を含むときはその文字以降を無視します。
...
self が空文字列のときは 0 を返します。
//emlist[例][ruby]{
p "10".hex # => 16
p "ff".hex # => 255
p "0x10".hex # => 16
p "-0x10".hex # => -16
p "xyz".hex # => 0
p "10z".hex # => 16
p "1_0".hex # => 16
p "".hex # => 0
//}
@see String#oct, String#to_i, String#to......_f,
Kernel.#Integer, Kernel.#Float
このメソッドの逆に数値を文字列に変換するには
Kernel.#sprintf, String#%,
Integer#to_s
などを使ってください。... -
String
# sub!(pattern , hash) -> String (19.0) -
文字列中の pattern にマッチした部分をキーにして hash を引いた値で破壊的に置き換えます。
...にマッチした部分をキーにして hash を引いた値で破壊的に置き換えます。
@param pattern 置き換える文字列のパターン
@param hash 置き換える文字列を与えるハッシュ
@return 置換した場合は self、置換しなかった場合は nil...