るりまサーチ

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

別のキーワード

  1. _builtin end
  2. ripper end_seen?
  3. _builtin exclude_end?
  4. _builtin end_with?
  5. psych end_stream

ライブラリ

クラス

モジュール

キーワード

検索結果

<< 1 2 3 > >>

Regexp.last_match(nth) -> String | nil (18333.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_matchnil を返すため、
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 番目の括弧にマッチした部分...

Regexp.last_match -> MatchData (18158.0)

カレントスコープで最後に行った正規表現マッチの 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 (6232.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
...

1.6.8から1.8.0への変更点(まとめ) (1242.0)

1.6.8から1.8.0への変更点(まとめ) * ((<1.6.8から1.8.0への変更点(まとめ)/インタプリタの変更>)) * ((<1.6.8から1.8.0への変更点(まとめ)/追加されたクラス/モジュール>)) * ((<1.6.8から1.8.0への変更点(まとめ)/追加されたメソッド>)) * ((<1.6.8から1.8.0への変更点(まとめ)/追加された定数>)) * ((<1.6.8から1.8.0への変更点(まとめ)/拡張されたクラス/メソッド(互換性のある変更)>)) * ((<1.6.8から1.8.0への変更点(まとめ)/変更されたクラス/メソッド(互換性のない変更)>)) * ((<1.6.8から1.8.0への変更点(まとめ)/文法の変更>)) * ((<1.6.8から1.8.0への変更点(まとめ)/正規表現>)) * ((<1.6.8から1.8.0への変更点(まとめ)/Marshal>)) * ((<1.6.8から1.8.0への変更点(まとめ)/Windows 対応>)) * ((<1.6.8から1.8.0への変更点(まとめ)/廃止された(される予定の)機能>)) * ((<1.6.8から1.8.0への変更点(まとめ)/ライブラリ>)) * ((<1.6.8から1.8.0への変更点(まとめ)/拡張ライブラリAPI>)) * ((<1.6.8から1.8.0への変更点(まとめ)/バグ修正>)) * ((<1.6.8から1.8.0への変更点(まとめ)/サポートプラットフォームの追加>))

...りました。
* nil: 警告を出力しない (-W0 新しい警告レベル)
* false: 重要な警告のみ出力 (-W1 デフォルト)
* true: すべての警告を出力する (-W2 or -W or -v or -w or --verbose)

追加された -W オプションは $VERBOSE = nil の指定(-W0)を...
...よくわかりません(^^;

class << Object
p [self.id, self]
class << self
p [self.id, self]
end

end

=> ruby 1.6.7 (2002-03-01) [i586-linux]
[537771634, Class]
[537742484, Class]
=> ruby 1.7.3 (2002-09...
...。((<ruby-dev:17968>))

=== Regexp

: ((<Regexp#===|Regexp/===>)) [compat]

真偽値を返すようになりました。

: ((<Regexp/Regexp.last_match>)) [compat]
optional な引数が追加されました。

=== String

: ((<String/String.new>)) [compat]

String.new の引数を...

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

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

...しなかった
場合、あるいは string が nil の場合には nil を返
します。

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

組み込み変数 $~ もしくは Regexp.last_match にマッチに関する情報 MatchData が設定...
... 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

un...
...less /foo/ === "bar"
puts "not match " # => not match
end


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

//}...

絞り込み条件を変える

Kernel$$1 -> String | nil (145.0)

最後に成功したパターンマッチで n 番目の括弧にマッチした値が格納されます。 該当する括弧がなければ nil が入っています。(覚え方: \数字 のようなもの)

...が格納されます。
該当する括弧がなければ nil が入っています。(覚え方: \数字 のようなもの)

番号 n はいくらでも大きな正整数を利用できます。

Regexp.last_match(1),
Regexp.last_match(2), ... と同じ。

これらの変数はローカルスコ...
...ープかつスレッドローカル、読み取り専用です。

//emlist[例][ruby]{
str = '<p><a href="http://example.com">example.com</a></p>'
if %r[<a href="(.*?)">(.*?)</a>] =~ str
print $1
print $2
end

#=> "http://example.com"
#=> "example.com"
//}...

Kernel$$10 -> String | nil (145.0)

最後に成功したパターンマッチで n 番目の括弧にマッチした値が格納されます。 該当する括弧がなければ nil が入っています。(覚え方: \数字 のようなもの)

...が格納されます。
該当する括弧がなければ nil が入っています。(覚え方: \数字 のようなもの)

番号 n はいくらでも大きな正整数を利用できます。

Regexp.last_match(1),
Regexp.last_match(2), ... と同じ。

これらの変数はローカルスコ...
...ープかつスレッドローカル、読み取り専用です。

//emlist[例][ruby]{
str = '<p><a href="http://example.com">example.com</a></p>'
if %r[<a href="(.*?)">(.*?)</a>] =~ str
print $1
print $2
end

#=> "http://example.com"
#=> "example.com"
//}...

Kernel$$11 -> String | nil (145.0)

最後に成功したパターンマッチで n 番目の括弧にマッチした値が格納されます。 該当する括弧がなければ nil が入っています。(覚え方: \数字 のようなもの)

...が格納されます。
該当する括弧がなければ nil が入っています。(覚え方: \数字 のようなもの)

番号 n はいくらでも大きな正整数を利用できます。

Regexp.last_match(1),
Regexp.last_match(2), ... と同じ。

これらの変数はローカルスコ...
...ープかつスレッドローカル、読み取り専用です。

//emlist[例][ruby]{
str = '<p><a href="http://example.com">example.com</a></p>'
if %r[<a href="(.*?)">(.*?)</a>] =~ str
print $1
print $2
end

#=> "http://example.com"
#=> "example.com"
//}...

Kernel$$2 -> String | nil (145.0)

最後に成功したパターンマッチで n 番目の括弧にマッチした値が格納されます。 該当する括弧がなければ nil が入っています。(覚え方: \数字 のようなもの)

...が格納されます。
該当する括弧がなければ nil が入っています。(覚え方: \数字 のようなもの)

番号 n はいくらでも大きな正整数を利用できます。

Regexp.last_match(1),
Regexp.last_match(2), ... と同じ。

これらの変数はローカルスコ...
...ープかつスレッドローカル、読み取り専用です。

//emlist[例][ruby]{
str = '<p><a href="http://example.com">example.com</a></p>'
if %r[<a href="(.*?)">(.*?)</a>] =~ str
print $1
print $2
end

#=> "http://example.com"
#=> "example.com"
//}...

Kernel$$3 -> String | nil (145.0)

最後に成功したパターンマッチで n 番目の括弧にマッチした値が格納されます。 該当する括弧がなければ nil が入っています。(覚え方: \数字 のようなもの)

...が格納されます。
該当する括弧がなければ nil が入っています。(覚え方: \数字 のようなもの)

番号 n はいくらでも大きな正整数を利用できます。

Regexp.last_match(1),
Regexp.last_match(2), ... と同じ。

これらの変数はローカルスコ...
...ープかつスレッドローカル、読み取り専用です。

//emlist[例][ruby]{
str = '<p><a href="http://example.com">example.com</a></p>'
if %r[<a href="(.*?)">(.*?)</a>] =~ str
print $1
print $2
end

#=> "http://example.com"
#=> "example.com"
//}...

絞り込み条件を変える

<< 1 2 3 > >>