318件ヒット
[1-100件を表示]
(0.095秒)
別のキーワード
種類
- インスタンスメソッド (164)
- 変数 (66)
- モジュール関数 (44)
- 文書 (22)
- 特異メソッド (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) - select! (11)
- size (11)
-
slice
_ when (11) - 制御構造 (11)
- 正規表現 (11)
検索結果
先頭5件
-
Gem
:: Platform # =~(other) -> bool (24300.0) -
自身と other のプラットフォームが一致する場合に真を返します。 そうでない場合は、偽を返します。
...合は、偽を返します。
other が文字列の場合は、まず Gem::Platform に変換してから比較を行います。
other が文字列でも Gem::Platform でもない場合は nil を返します。
@param other 比較対象のオブジェクトです。
@see Gem::Platform#===... -
Regexp
. last _ match -> MatchData (12515.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
//}... -
Kernel
$ $ LAST _ MATCH _ INFO -> MatchData | nil (12512.0) -
$~ の別名
...nglish"
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.txt"
p $LAST_MATCH......_INFO[2] #=> nil
end... -
Kernel
$ $ LAST _ PAREN _ MATCH -> String | nil (12348.0) -
$+ の別名
...glish"
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>ikkou</td> <td><a href=http://lo......calhost/link.html>link</a></td> </tr>
#enf of sample.rb
$ ruby sample.rb
"http://localhost/a.jpg"
"link"... -
Regexp
. last _ match(nth) -> String | nil (12320.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 番目の括弧にマッチした部... -
MatchData
# length -> Integer (12206.0) -
部分文字列の数を返します(self.to_a.size と同じです)。
...部分文字列の数を返します(self.to_a.size と同じです)。
//emlist[例][ruby]{
/(foo)(bar)(BAZ)?/ =~ "foobarbaz"
p $~.size # => 4
//}... -
Kernel
$ $ MATCH -> String | nil (9306.0) -
$& の別名
...$& の別名
require "English"
str = 'hoge,foo,bar,hee,hoo'
/(foo|bar)/ =~ str
p $MATCH #=> "foo"... -
Kernel
$ $ POSTMATCH -> String | nil (9306.0) -
$' の別名
...$' の別名
require "English"
str = 'hoge,foo,bar,hee,hoo'
/foo/ =~ str
p $POSTMATCH #=> ",bar,hee,hoo"... -
Kernel
$ $ PREMATCH -> String | nil (9306.0) -
$` の別名
...$` の別名
require "English"
str = 'hoge,foo,bar,hee,hoo'
/foo/ =~ str
p $PREMATCH #=> "hoge,"... -
MatchData
# size -> Integer (9106.0) -
部分文字列の数を返します(self.to_a.size と同じです)。
...部分文字列の数を返します(self.to_a.size と同じです)。
//emlist[例][ruby]{
/(foo)(bar)(BAZ)?/ =~ "foobarbaz"
p $~.size # => 4
//}...