るりまサーチ

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

別のキーワード

  1. _builtin -
  2. open-uri open
  3. irb/input-method gets
  4. irb/input-method new
  5. matrix -

ライブラリ

モジュール

キーワード

検索結果

<< 1 2 3 ... > >>

MatchData#end(n) -> Integer | nil (21237.0)

n 番目の部分文字列終端のオフセットを返します。

...IndexError 範囲外の n を指定した場合に発生します。

//emlist[例][ruby]{
/(foo)(bar)(BAZ)?/ =~ "foobarbaz"
p $~.end(0) # => 6
p $~.end(1) # => 3
p $~.end(2) # => 6
p $~.end(3) # => nil
p $~.end(4) # => `end': index 4 out of matches (IndexError)
//}

@see MatchData#begin...

Regexp#match(str, pos = 0) -> MatchData | nil (18416.0)

指定された文字列 str に対して位置 pos から自身が表す正規表現によるマッ チングを行います。マッチした場合には結果を MatchData オブジェクトで返し ます。 マッチしなかった場合 nil を返します。

...字列 str に対して位置 pos から自身が表す正規表現によるマッ
チングを行います。マッチした場合には結果を MatchData オブジェクトで返し
ます。
マッチしなかった場合 nil を返します。

省略可能な第二引数 pos を指定すると...
...captures) # => ["b", "r"]
p(/(.).(.)/.match("foobar", -3).captures) # => ["b", "r"]
//}

pos を指定しても MatchData#offset 等の結果
には影響しません。つまり、
//emlist[][ruby]{
re.match(str[pos..-1])
//}

//emlist[][ruby]{
re.match(str, pos)
//}
は異なります。...
...ルト値は 0)。

//emlist[例][ruby]{
reg = Regexp.new("foo")

if reg.match("foobar")
puts "match"
end

# => match

p reg.match("foobar") # => #<MatchData:0x29403fc>
p reg.match("bar") # => nil

p /(foo)(bar)(baz)/.match("foobarbaz").to_a.values_at(1,2,3) # => ["foo", "bar", "baz"]
//}

===...

Regexp#match(str, pos = 0) {|m| ... } -> object | nil (18316.0)

指定された文字列 str に対して位置 pos から自身が表す正規表現によるマッ チングを行います。マッチした場合には結果を MatchData オブジェクトで返し ます。 マッチしなかった場合 nil を返します。

...字列 str に対して位置 pos から自身が表す正規表現によるマッ
チングを行います。マッチした場合には結果を MatchData オブジェクトで返し
ます。
マッチしなかった場合 nil を返します。

省略可能な第二引数 pos を指定すると...
...captures) # => ["b", "r"]
p(/(.).(.)/.match("foobar", -3).captures) # => ["b", "r"]
//}

pos を指定しても MatchData#offset 等の結果
には影響しません。つまり、
//emlist[][ruby]{
re.match(str[pos..-1])
//}

//emlist[][ruby]{
re.match(str, pos)
//}
は異なります。...
...ルト値は 0)。

//emlist[例][ruby]{
reg = Regexp.new("foo")

if reg.match("foobar")
puts "match"
end

# => match

p reg.match("foobar") # => #<MatchData:0x29403fc>
p reg.match("bar") # => nil

p /(foo)(bar)(baz)/.match("foobarbaz").to_a.values_at(1,2,3) # => ["foo", "bar", "baz"]
//}

===...

Gem::SpecFetcher#find_matching(dependency, all = false, matching_platform = true) -> Array (6400.0)

依存関係を満たす gemspec の名前の配列を返します。

...返します。

@param dependency 依存関係を指定します。
@param all 真を指定するとマッチする全てのバージョンの情報を返します。
@param matching_platform 偽を指定すると全てのプラットフォームの情報を返します。

@see Gem::Dependency...

Regexp.last_match -> MatchData (6344.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 (6343.0)

$~ の別名

...f=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
...

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

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

..."
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 番目の括弧にマッチした部分文字列を返します。...

StringScanner#match?(regexp) -> Integer | nil (6237.0)

スキャンポインタの地点だけで regexp と文字列のマッチを試します。 マッチしたら、スキャンポインタは進めずにマッチした 部分文字列の長さを返します。マッチしなかったら nil を 返します。

...e))
s.match?(/#{"\u{308B}".encode(encode)}/)
end


p case1("EUC-JP") #=> 2
//}

@param regexp マッチに用いる正規表現を指定します。

//emlist[例][ruby]{
require 'strscan'

s = StringScanner.new('test string')
p s.match?(/\w+/) #=> 4
p s.match?(/\w+/) #=> 4
p s.match?(/\s+/...

StringScanner#matched_size -> Integer | nil (6218.0)

前回マッチした部分文字列の長さを返します。 前回マッチに失敗していたら nil を返します。

...e)}/)
s.matched_size
end


p run("UTF-8") #=> 3
p run("EUC-JP") #=> 2
p run("Shift_Jis") #=> 2

//}

//emlist[例][ruby]{
require 'strscan'

s = StringScanner.new('test string')
s.matched_size # => nil
s.scan(/\w+/) # => "test"
s.matched_size # => 4
s.scan(/\w+/) # => nil
s.matched_size #...

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

$+ の別名

...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://localhost/link.html>link</a></td> </tr>
#enf of sample....

絞り込み条件を変える

<< 1 2 3 ... > >>