るりまサーチ

最速Rubyリファレンスマニュアル検索!
329件ヒット [1-100件を表示] (0.188秒)
トップページ > クエリ:-[x] > クエリ:r[x] > クエリ:at[x] > クエリ:l[x] > クエリ:=~[x]

別のキーワード

  1. _builtin to_r
  2. open3 pipeline_r
  3. matrix elements_to_r
  4. fileutils rm_r
  5. fileutils cp_r

ライブラリ

クラス

モジュール

キーワード

検索結果

<< 1 2 3 ... > >>

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

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

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

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

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

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

Kernel$$LAST_PAREN_MATCH -> String | nil (18430.0)

$+ の別名

...$+ の別名

r
equire "English"

r
1 = Regexp.compile("<img src=(http:.+?)>")
r
2 = Regexp.compile("<a href=(http|ftp).+?>(.+?)</a>")

while line = DATA.gets
[ r1, r2 ].each {|rep|
r
ep =~ line
p $+
}
end
__END__
<tr> <td><img src=http://localhost/a.jpg></td> <td>ikko...
...u</td> <td><a href=http://localhost/link.html>link</a></td> </tr>
#enf of sample.rb

$ ruby sample.rb
"http://localhost/a.jpg"
"link"...

Kernel$$LAST_MATCH_INFO -> MatchData | nil (15524.0)

$~ の別名

...別名

r
equire "English"

str = "<a href=https://www.ruby-lang.org/en/about/license.txt>license</a>"

if /<a href=(.+?)>/ =~ str
p $LAST_MATCH_INFO[0] #=> "<a href=https://www.ruby-lang.org/en/about/license.txt>"
p $LAST_MATCH_INFO[1] #=> "https://www.ruby-lang.org/en/about/license.tx...
...t"
p $LAST_MATCH_INFO[2] #=> nil
end...

Regexp.last_match -> MatchData (15508.0)

カレントスコープで最後に行った正規表現マッチの MatchData オ ブジェクトを返します。このメソッドの呼び出しは $~ の参照と同じです。

...MatchData オ
ブジェクトを返します。このメソッドの呼び出しは $~
の参照と同じです。

//emlist[例][ruby]{
/(.)(.)/ =~ "ab"
p Regexp.last_match # => #<MatchData:0x4599e58>
p Regexp.last_match[0] # => "ab"
p Regexp.last_match[1] # => "a"
p Regexp.last_match[2]...
...# => "b"
p Regexp.last_match[3] # => nil
//}...

Regexp.last_match(nth) -> String | nil (15413.0)

整数 nth が 0 の場合、マッチした文字列を返します ($&)。それ以外では、nth 番目の括弧にマッチ した部分文字列を返します($1,$2,...)。 対応する括弧がない場合やマッチしなかった場合には nil を返し ます。

...かった場合には nil を返し
ます。

//emlist[例][ruby]{
/(.)(.)/ =~ "ab"
p Regexp.last_match # => #<MatchData:0x4599e58>
p Regexp.last_match(0) # => "ab"
p Regexp.last_match(1) # => "a"
p Regexp.last_match(2) # => "b"
p Regexp.last_match(3) # => nil
//}

正規表現全体...
...
R
egexp.last_match はnil を返すため、
l
ast_match[1] の形式では例外 NoMethodError が発生します。
対して、last_match(1) は nil を返します。

//emlist[例][ruby]{
str = "This is Regexp"
/That is Regexp/ =~ str
p Regexp.last_match # => nil
begin
p Regexp.last_match[1...
...] # 例外が発生する
r
escue
puts $! # => undefined method `[]' for nil:NilClass
end
p Regexp.last_match(1) # => nil
//}

@param nth 整数を指定します。
整数 nth が 0 の場合、マッチした文字列を返します。それ以外では、nth 番目の括弧にマッチした...

絞り込み条件を変える

Kernel$$PREMATCH -> String | nil (15406.0)

$` の別名

...$` の別名

r
equire "English"

str = 'hoge,foo,bar,hee,hoo'

/foo/ =~ str
p $PREMATCH #=> "hoge,"...

Array#filter! -> Enumerator (12412.0)

ブロックが真を返した要素を残し、偽を返した要素を自身から削除します。 変更があった場合は self を、 変更がなかった場合には nil を返します。

...self を、
変更がなかった場合には nil を返します。

//emlist[例][ruby]{
a = %w{ a b c d e f }
a.select! {|v| v =~ /[a-z]/ } # => nil
a # => ["a", "b", "c", "d", "e", "f"]
//}

ブロックが与えられなかった場合は、自身と select! から生成した
Enumerator...
...ブジェクトを返します。

@see Array#keep_if, Array#reject!...

Kernel$$MATCH -> String | nil (12406.0)

$& の別名

...$& の別名

r
equire "English"

str = 'hoge,foo,bar,hee,hoo'

/(foo|bar)/ =~ str
p $MATCH #=> "foo"...

Kernel$$POSTMATCH -> String | nil (12406.0)

$' の別名

...$' の別名

r
equire "English"

str = 'hoge,foo,bar,hee,hoo'

/foo/ =~ str
p $POSTMATCH #=> ",bar,hee,hoo"...

Kernel.#caller(range) -> [String] | nil (12318.0)

start 段上の呼び出し元の情報を $@ の形式のバックトレース(文字列の配列)として返します。

...start 段上の呼び出し元の情報を $@
の形式のバックトレース(文字列の配列)として返します。

トップレベルでは空の配列を返します。caller の戻り値を $@ に代入することで
例外の発生位置を設定できます。

引数で指定した...
...ram length 取得するスタックの個数を指定します。

@param range 取得したいスタックの範囲を示す Range オブジェクトを指定します。

@see Kernel.#set_trace_func,Kernel.#raise,
Kernel.#caller_locations

//emlist[例][ruby]{
def foo
p caller(0)
p caller...
...(1)
p caller(2)
p caller(3)
p caller(4)
end

def bar
foo
end

bar

#=> ["-:2:in `foo'", "-:10:in `bar'", "-:13:in `<main>'"]
# ["-:10:in `bar'", "-:13:in `<main>'"]
# ["-:13:in `<main>'"]
# []
# nil
//}

以下の関数は、caller の要素から [ファイル名, 行番号, メソ...

絞り込み条件を変える

<< 1 2 3 ... > >>