るりまサーチ

最速Rubyリファレンスマニュアル検索!
74件ヒット [1-74件を表示] (0.029秒)
トップページ > クエリ:true[x] > クエリ:_builtin[x] > クラス:Regexp[x]

別のキーワード

  1. _builtin true
  2. object true
  3. rb_true
  4. true object

ライブラリ

キーワード

検索結果

Regexp#==(other) -> bool (8029.0)

otherが同じパターン、オプション、文字コードの正規表現であったらtrueを返します。

...たらtrueを返します。

@param other 正規表現を指定します。

//emlist[例][ruby]{
p /^eee$/ == /~eee$/x # => false
p /^eee$/ == /~eee$/i # => false
p /^eee$/e == /~eee$/u # => false
p /^eee$/ == Regexp.new("^eee$") # => true
p /^eee$/.eql?(/^eee$/) # => true
//}...

Regexp#eql?(other) -> bool (8029.0)

otherが同じパターン、オプション、文字コードの正規表現であったらtrueを返します。

...たらtrueを返します。

@param other 正規表現を指定します。

//emlist[例][ruby]{
p /^eee$/ == /~eee$/x # => false
p /^eee$/ == /~eee$/i # => false
p /^eee$/e == /~eee$/u # => false
p /^eee$/ == Regexp.new("^eee$") # => true
p /^eee$/.eql?(/^eee$/) # => true
//}...

Regexp#match?(str, pos = 0) -> bool (8023.0)

指定された文字列 str に対して 位置 pos から自身が表す正規表現によるマッチングを行います。 マッチした場合 true を返し、マッチしない場合には false を返します。 また、$~ などパターンマッチに関する組み込み変数の値は変更されません。

...います。
マッチした場合 true を返し、マッチしない場合には false を返します。
また、$~ などパターンマッチに関する組み込み変数の値は変更されません。

//emlist[例][ruby]{
/R.../.match?("Ruby") # => true
/R.../.match?("Ruby", 1) # => fa...
...lse
/P.../.match?("Ruby") # => false
$& # => nil
//}

@see Regexp#match...

Regexp#fixed_encoding? -> bool (8013.0)

正規表現が任意の ASCII 互換エンコーディングとマッチ可能な時に false を返します。

...encoding("euc-jp") # => 2
r =~ "abc".force_encoding("euc-jp") # => 0

r = /a/u
r.fixed_encoding? # => true
r.encoding # => #<Encoding:UTF-8>
r =~ "\u{6666} a" # => 2
begin
r =~ "\xa1\x...
...::CompatibilityError
end
r =~ "abc".force_encoding("euc-jp") # => 0

r = /\u{6666}/
r.fixed_encoding? # => true
r.encoding # => #<Encoding:UTF-8>
r =~ "\u{6666} a" # => 0
begin
r =~ "\xa1\x...

Regexp#===(string) -> bool (8007.0)

文字列 string との正規表現マッチを行います。 マッチした場合は真を返します。

...対象文字列

//emlist[例][ruby]{
a = "HELLO"
case a
when /\A[a-z]*\z/; puts "Lower case"
when /\A[A-Z]*\z/; puts "Upper case"
else; puts "Mixed case"
end
# => Upper case

/\A[a-z]*\z/ === "HELLO" # => false
/\A[A-Z]*\z/ === "HELLO" # => true
//}

@see Enumerable#grep, Object#===...

絞り込み条件を変える

Regexp#casefold? -> bool (8007.0)

正規表現が大文字小文字の判定をしないようにコンパイルされている時、 真を返します。

...正規表現が大文字小文字の判定をしないようにコンパイルされている時、
真を返します。

//emlist[例][ruby]{
reg = Regexp.new("foobar", Regexp::IGNORECASE)
p reg.casefold? # => true

reg = Regexp.new("hogehoge")
p reg.casefold? # => false
//}...

Regexp#~ -> Integer | nil (8007.0)

変数 $_ の値との間でのマッチをとります。

...> no match
# ただし、警告がでる。warning: regex literal in condition

reg = Regexp.compile("foo")

if ~ reg
puts "match"
else
puts "no match"
end
# => no match

if reg
puts "match"
else
puts "no match"
end
# => match
# reg は nil でも false でも無いので常にtrue
//}...