るりまサーチ

最速Rubyリファレンスマニュアル検索!
408件ヒット [1-100件を表示] (0.158秒)

別のキーワード

  1. openssl p
  2. openssl p=
  3. fileutils mkdir_p
  4. dh p=
  5. dh p

クラス

モジュール

キーワード

検索結果

<< 1 2 3 ... > >>

Regexp#=~(string) -> Integer | nil (21191.0)

文字列 string との正規表現マッチを行います。マッチした場合、 マッチした位置のインデックスを返します(先頭は0)。マッチしなかった 場合、あるいは string が nil の場合には nil を返 します。

...][ruby]{
p
/foo/ =~ "foo" # => 0
p
/foo/ =~ "afoo" # => 1
p
/foo/ =~ "bar" # => nil
//}

組み込み変数 $~ もしくは Regexp.last_match にマッチに関する情報 MatchData が設定されます。

文字列のかわりにSymbolをマッチさせることができます。

@param strin...
...ise TypeError string が nil でも String オブジェクト
でも Symbol でもない場合発生します。

//emlist[例][ruby]{
p
/foo/ =~ "foo" # => 0
p
Regexp.last_match(0) # => "foo"
p
/foo/ =~ "afoo" # => 1
p
$~[0] # => "foo"
p
/foo/ =~ "bar"...
...# => nil

unless /foo/ === "bar"
p
uts "not match " # => not match
end

str = []
begin
/ugo/ =~ str
rescue TypeError
p
rintf "! %s\t%s\n", $!, $@ # => ! can't convert Array into String r5.rb:15
end
//}...

Gem::Dependency#=~(other) -> bool (21101.0)

self と other を比較して真偽値を返します。

...self と other を比較して真偽値を返します。

self の Gem::Dependency#name が正規表現として other とマッチしない場合は偽を返します。
self が other との依存関係を満たしていれば真を返します。満たしていなければ偽を返します。...

Gem::Platform#=~(other) -> bool (21101.0)

自身と other のプラットフォームが一致する場合に真を返します。 そうでない場合は、偽を返します。

...合は、偽を返します。

other が文字列の場合は、まず Gem::Platform に変換してから比較を行います。
other が文字列でも Gem::Platform でもない場合は nil を返します。

@param other 比較対象のオブジェクトです。

@see Gem::Platform#===...

String#=~(other) -> Integer | nil (18149.0)

正規表現 other とのマッチを行います。 マッチが成功すればマッチした位置のインデックスを、そうでなければ nil を返します。

...ない場合は
other =~ self を行います。

このメソッドが実行されると、組み込み変数 $~, $1, ...
にマッチに関する情報が設定されます。

@param other 正規表現もしくは =~ メソッドを持つオブジェクト
@raise TypeError other が文...
...字列の場合に発生します。

//emlist[例][ruby]{
p
"string" =~ /str/ # => 0
p
"string" =~ /not/ # => nil
p
"abcfoo" =~ /foo/ # => 3
//}...

Symbol#=~(other) -> Integer | nil (18143.0)

正規表現 other とのマッチを行います。

....to_s =~ other と同じです。)

@param other 比較対象のシンボルを指定します。

@return マッチが成功すればマッチした位置のインデックスを、そうでなければ nil を返します。

p
:foo =~ /foo/ # => 0
p
:foobar =~ /bar/ # => 3
p
:foo =~ /bar...
.../ # => nil

@see String#=~...

絞り込み条件を変える

NilClass#=~(other) -> nil (18141.0)

右辺に正規表現オブジェクトを置いた正規表現マッチ obj =~ /RE/ をサポートするためのメソッドです。常に nil を返します。

...現マッチ obj =~ /RE/
をサポートするためのメソッドです。常に nil を返します。


@param other 任意のオブジェクトです。結果に影響しません。

//emlist[例][ruby]{
obj = 'regexp'
p
(obj =~ /re/) #=> 0

obj = nil
p
(obj =~ /re/) #=> nil
//}

@see String#=~...

Object#=~(other) -> nil (18141.0)

右辺に正規表現オブジェクトを置いた正規表現マッチ obj =~ /RE/ をサポートするためのメソッドです。常に nil を返します。

...表現オブジェクトを置いた正規表現マッチ obj =~ /RE/
をサポートするためのメソッドです。常に nil を返します。

このメソッドは Ruby 2.6 から deprecated です。

この定義により、=~ が再定義されたオブジェクトでは正常にマッ...
...チを行い、
それ以外のものは nil を返すようになります。


@param other 任意のオブジェクトです。結果に影響しません。

//emlist[例][ruby]{
obj = 'regexp'
p
(obj =~ /re/) #=> 0

obj = nil
p
(obj =~ /re/) #=> nil
//}

@see String#=~...
...ッチ obj =~ /RE/
をサポートするためのメソッドです。常に nil を返します。

このメソッドは Ruby 2.6 から deprecated です。

意図せずに Array などに対して呼ばれた時にバグの原因になっていたため、
代わりに NilClass#=~ が定義さ...
...れています。

@param other 任意のオブジェクトです。結果に影響しません。

//emlist[例][ruby]{
obj = 'regexp'
p
(obj =~ /re/) #=> 0

obj = nil
p
(obj =~ /re/) #=> nil
//}

@see String#=~...

Gem::Requirement#=~(version) -> bool (15113.0)

引数 version が自身に含まれる全ての必要条件を満たす場合に true を返します。 そうでなければ、false を返します。

...
そうでなければ、false を返します。

@param version Gem::Version のインスタンスを指定します。

//emlist[][ruby]{
req = Gem::Requirement.new("~> 3.2.1")

p
req.satisfied_by?(Gem::Version.new('3.2.9')) # => true
p
req.satisfied_by?(Gem::Version.new('3.3.0')) # => false...

MatchData#captures -> [String] (6119.0)

$1, $2, ... を格納した配列を返します。

...ープにマッチした部分文字列がなければ対応する要素は nil になります。

//emlist[例][ruby]{
/(foo)(bar)(BAZ)?/ =~ "foobarbaz"
p
$~.to_a # => ["foobar", "foo", "bar", nil]
p
$~.captures # => ["foo", "bar", nil]
//}

@see MatchData#to_a, MatchData#named_captures...
...応する要素は nil になります。

//emlist[例][ruby]{
/(foo)(bar)(BAZ)?/ =~ "foobarbaz"
p
$~.to_a # => ["foobar", "foo", "bar", nil]
p
$~.captures # => ["foo", "bar", nil]
//}

@see MatchData#to_a, MatchData#named_captures, d:spec/pattern_matching#matching_non_primitive_objects...
<< 1 2 3 ... > >>