329件ヒット
[1-100件を表示]
(0.188秒)
種類
- インスタンスメソッド (164)
- 変数 (66)
- モジュール関数 (44)
- 文書 (33)
- 特異メソッド (22)
ライブラリ
- English (55)
- ビルトイン (230)
-
rubygems
/ platform (11)
クラス
- Array (17)
-
Gem
:: Platform (11) - MatchData (103)
- Object (11)
- Regexp (22)
モジュール
- Enumerable (22)
- Kernel (110)
キーワード
-
$ LAST _ MATCH _ INFO (11) -
$ LAST _ PAREN _ MATCH (11) -
$ MATCH (11) -
$ POSTMATCH (11) -
$ PREMATCH (11) -
$ ~ (11) - [] (33)
- begin (11)
- byteoffset (4)
- caller (33)
- chunk (11)
- end (11)
- filter! (6)
-
last
_ match (22) - length (11)
- loop (11)
- offset (22)
-
respond
_ to _ missing? (11) -
ruby 1
. 8 . 2 feature (11) - select! (11)
- size (11)
-
slice
_ when (11) - 制御構造 (11)
- 正規表現 (11)
検索結果
先頭5件
-
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) -
$+ の別名
...$+ の別名
require "English"
r1 = Regexp.compile("<img src=(http:.+?)>")
r2 = Regexp.compile("<a href=(http|ftp).+?>(.+?)</a>")
while line = DATA.gets
[ r1, r2 ].each {|rep|
rep =~ 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) -
$~ の別名
...別名
require "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
//}
正規表現全体......の
Regexp.last_match はnil を返すため、
last_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......] # 例外が発生する
rescue
puts $! # => undefined method `[]' for nil:NilClass
end
p Regexp.last_match(1) # => nil
//}
@param nth 整数を指定します。
整数 nth が 0 の場合、マッチした文字列を返します。それ以外では、nth 番目の括弧にマッチした... -
Kernel
$ $ PREMATCH -> String | nil (15406.0) -
$` の別名
...$` の別名
require "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) -
$& の別名
...$& の別名
require "English"
str = 'hoge,foo,bar,hee,hoo'
/(foo|bar)/ =~ str
p $MATCH #=> "foo"... -
Kernel
$ $ POSTMATCH -> String | nil (12406.0) -
$' の別名
...$' の別名
require "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 の要素から [ファイル名, 行番号, メソ...