るりまサーチ

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

別のキーワード

  1. _builtin new
  2. _builtin inspect
  3. _builtin []
  4. _builtin to_s
  5. _builtin each

ライブラリ

クラス

キーワード

検索結果

<< 1 2 3 > >>

Regexp (46072.0)

正規表現のクラス。正規表現のリテラルはスラッシュで囲んだ形式 で記述します。

...]{
/^this is regexp/
//}

Regexp
.new(string) を使って正規表現オブジェクトを動的に生成する
こともできます。

//emlist[][ruby]{
str = "this is regexp"
rp1 = Regexp.new("^this is regexp")
p rp1 =~ str # => 0
p Regexp.last_match[0] # => "this is regexp"
//}

Ruby...
...3.0.0 から正規表現リテラルは freeze されるようになりました。
//emlist[][ruby]{
p /abc/.frozen?
# => true
p /a#{42}bc/.frozen?
# => true
p Regexp.new('abc').frozen?
# => false
//}

spec/regexp や d:spec/literal#regexp も参照してください。...

Regexp#==(other) -> bool (29034.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 (29034.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 (29028.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#casefold? -> bool (29024.0)

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

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

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

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

絞り込み条件を変える

Regexp#fixed_encoding? -> bool (29012.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#~ -> Integer | nil (29012.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
//}...

Regexp#===(string) -> bool (29006.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#===...

Symbol#match?(regexp, pos = 0) -> bool (8173.0)

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

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

例:

:Ruby.match?(/R.../) # => true
:Ruby.match?('Ruby') # => true
:Ruby.match?('Ruby',1) # => false
:R...
...uby.match?('uby',1) # => true
:Ruby.match?(/P.../) # => false
$& # => nil

@see Regexp#match?, String#match?...

String#match?(regexp, pos = 0) -> bool (8161.0)

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

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

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

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

絞り込み条件を変える

String#[](regexp, name) -> String (8129.0)

正規表現 regexp の name で指定した名前付きキャプチャにマッチする最初の 部分文字列を返します。正規表現が self にマッチしなかった場合は nil を返 します。

...正規表現 regexp の name で指定した名前付きキャプチャにマッチする最初の
部分文字列を返します。正規表現が self にマッチしなかった場合は nil を返
します。

@param regexp 正規表現を指定します。
@param name 取得したい部分文...
<< 1 2 3 > >>