キーワード
- % (12)
- * (12)
- + (12)
- << (12)
- <=> (12)
- == (12)
- === (12)
- =~ (12)
- [] (72)
- []= (84)
- byteindex (3)
- byterindex (3)
- byteslice (36)
- bytesplice (10)
- capitalize (9)
- capitalize! (9)
- casecmp (12)
- casecmp? (9)
- center (12)
- concat (21)
- count (12)
- crypt (12)
- delete (12)
- delete! (12)
-
delete
_ prefix (8) -
delete
_ prefix! (8) -
delete
_ suffix (8) -
delete
_ suffix! (8) - downcase (9)
- downcase! (9)
-
each
_ line (24) - encode (36)
- encode! (24)
-
end
_ with? (12) - eql? (12)
- ext (12)
-
force
_ encoding (12) - getbyte (12)
- gsub (48)
- gsub! (48)
- include? (12)
- index (12)
- insert (12)
- kconv (12)
- lines (24)
- ljust (12)
-
parse
_ csv (12) - partition (12)
-
pathmap
_ replace (12) - prepend (21)
- rindex (12)
- rjust (12)
- rpartition (12)
- scan (24)
- scanf (12)
- scrub (36)
- scrub! (36)
- setbyte (12)
- slice (72)
- split (19)
- squeeze (12)
- squeeze! (12)
-
start
_ with? (12) - sub (36)
- sub! (36)
- sum (12)
- swapcase (9)
- swapcase! (9)
-
to
_ i (12) - tr (12)
- tr! (12)
-
tr
_ s (12) -
tr
_ s! (12) -
unicode
_ normalize (11) -
unicode
_ normalize! (11) -
unicode
_ normalized? (11) - unpack (12)
- upcase (9)
- upcase! (9)
- upto (12)
検索結果
先頭5件
-
String
# squeeze(*chars) -> String (30210.0) -
chars に含まれる文字が複数並んでいたら 1 文字にまとめます。
...1 文字にまとめます。
引数を複数指定した場合は、すべての引数にマッチする文字を 1 文字にまとめます。
@param chars 1文字にまとめる文字。
//emlist[例][ruby]{
p "112233445566778899".squeeze # =>"123456789"
p "112233445566778899".squee... -
String
# eql?(other) -> bool (30176.0) -
文字列の内容が文字列 other の内容と等しいときに true を返します。 等しくなければ false を返します。
...します。
同一のオブジェクトかどうかを比較するわけではありません。
つまり、"string".eql?(str) という式を実行した場合には、
str が "string" という内容の文字列でありさえすれば常に true を返します。
同一のオブジェクト......場合は
String#casecmp? を使ってください。
Hash クラス内での比較に使われます。
@param other 任意のオブジェクト
@return true か false
//emlist[例][ruby]{
p "string".eql?("string") # => true
p "string".eql?("STRING") # => false
p "string".eql?("")......# => false
p "".eql?("string") # => false
p "string".eql?("str" + "ing") # => true (内容が同じなら true)
p "string".eql?("stringX".chop) # => true (内容が同じなら true)
//}
@see Hash, String#<=>, String#casecmp, String#==... -
String
# upcase!(*options) -> self | nil (30116.0) -
全ての小文字を対応する大文字に破壊的に置き換えます。 どの文字がどう置き換えられるかは、オプションの有無や文字列のエンコーディングに依存します。
...ディングに依存します。
@param options オプションの詳細は String#downcase を参照してください。
//emlist[例][ruby]{
buf = "stRIng? STring."
buf.upcase!
p buf # => "STRING? STRING."
//}
@see String#upcase, String#downcase!,
String#swapcase!, String#capitalize!... -
String
# ==(other) -> bool (30112.0) -
other が文字列の場合、String#eql? と同様に文字列の内容を比較します。
...、String#eql? と同様に文字列の内容を比較します。
other が文字列でない場合、
other.to_str が定義されていれば
other == self の結果を返します。(ただし、 other.to_str は実行されません。)
そうでなければ false を返します。
@param ot......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 (30112.0) -
other が文字列の場合、String#eql? と同様に文字列の内容を比較します。
...、String#eql? と同様に文字列の内容を比較します。
other が文字列でない場合、
other.to_str が定義されていれば
other == self の結果を返します。(ただし、 other.to_str は実行されません。)
そうでなければ false を返します。
@param ot......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
# sub!(pattern , replace) -> self | nil (30105.0) -
文字列中で pattern にマッチした最初の部分を文字列 replace へ破壊的に置き換えます。
...らなかった場合は nil を返します。
@param pattern 置き換える文字列のパターンを表す文字列か正規表現。
文字列を指定した場合は全く同じ文字列にだけマッチする
@param replace pattern で指定した文字列と置き......合は self、置換しなかった場合は nil
//emlist[例][ruby]{
buf = "String-String"
buf.sub!(/in./, "!!")
p buf # => "Str!!-String"
buf = "String.String"
buf.sub!(/in./, '<<\&>>')
p buf # => "Str<<ing>>-String"
//}
注意:
引数 replace の中で $1 を使うことはできません......b!(/a(b+)/, "#{$1}") # NG
'abbbcd'.sub!(/a(b+)/, "\1") # NG
'abbbcd'.sub!(/a(b+)/, "\\1") # OK
'abbbcd'.sub!(/a(b+)/, '\\1') # OK
'abbbcd'.sub!(/a(b+)/, '\1') # OK
'abbbcd'.sub!(/a(b+)/) { $1 } # OK これがもっとも安全
//}
@see String#gsub... -
String
# start _ with?(*prefixes) -> bool (30104.0) -
self の先頭が prefixes のいずれかであるとき true を返します。
...param prefixes パターンを表す文字列または正規表現 (のリスト)
//emlist[例][ruby]{
"string".start_with?("str") # => true
"string".start_with?("ing") # => false
"string".start_with?("ing", "str") # => true
"string".start_with?(/\w/) # => true
"string......".start_with?(/\d/) # => false
//}
@see String#end_with?
@see String#delete_prefix, String#delete_prefix!... -
String
# downcase!(*options) -> self | nil (30092.0) -
全ての大文字を対応する小文字に破壊的に置き換えます。 どの文字がどう置き換えられるかは、オプションの有無や文字列のエンコーディングに依存します。
...@param options オプションの詳細は String#downcase を参照してください。
@return self を変更して返します。変更が無かった場合は nil を返します。
//emlist[例][ruby]{
str = "STRing?"
str.downcase!
p str # => "string?"
//}
@see String#downcase, String#up......case!, String#swapcase!, String#capitalize!... -
String
# gsub!(pattern , replace) -> self | nil (30091.0) -
文字列中で pattern にマッチする部分全てを文字列 replace に破壊的に置き換えます。
...らなかった場合は nil を返します。
@param pattern 置き換える文字列のパターンを表す文字列か正規表現。
文字列を指定した場合は全く同じ文字列にだけマッチする
@param replace pattern で指定した文字列と置き......列
@return 置換した場合は self、置換しなかった場合は nil
//emlist[例][ruby]{
buf = "String-String"
buf.gsub!(/in./, "!!")
p buf # => "Str!!-Str!!"
buf = "String.String"
buf.gsub!(/in./, '<<\&>>')
p buf # => "Str<<ing>>-Str<<ing>>"
//}
注意:
引数 replace の中で $1......}") # NG
'abbbcd'.gsub!(/a(b+)/, "\1") # NG
'abbbcd'.gsub!(/a(b+)/, "\\1") # OK
'abbbcd'.gsub!(/a(b+)/, '\\1') # OK
'abbbcd'.gsub!(/a(b+)/, '\1') # OK
'abbbcd'.gsub!(/a(b+)/) { $1 } # OK これがもっとも安全
//}
@see String#sub, String#gsub... -
String
# end _ with?(*strs) -> bool (30080.0) -
self の末尾が strs のいずれかであるとき true を返します。
...す。
@param strs パターンを表す文字列 (のリスト)
//emlist[例][ruby]{
"string".end_with?("ing") # => true
"string".end_with?("str") # => false
"string".end_with?("str", "ing") # => true
//}
@see String#start_with?
@see String#delete_suffix, String#delete_suf...