るりまサーチ

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

別のキーワード

  1. _builtin >
  2. bigdecimal >
  3. float >
  4. complex >
  5. comparable >

ライブラリ

クラス

モジュール

検索結果

StringScanner#post_match -> String | nil (18337.0)

前回マッチを行った文字列のうち、マッチしたところよりも後ろの 部分文字列を返します。前回のマッチが失敗していると常に nil を 返します。

...nil
返します。

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

s = StringScanner.new('test string')
s.post_match # => nil
s.scan(/\w+/) # => "test"
s.post_match # => " string"
s.scan(/\w+/) # => nil
s.post_match # => nil
s.scan(/\s+/) # => " "
s.post_match # => "string"
s.scan(/\w+/) # => "st...
...ring"
s.post_match # => ""
s.scan(/\w+/) # => nil
s.post_match # => nil
//}...

Kernel$$' -> String | nil (3206.0)

現在のスコープで最後に成功した正規表現のパターンマッチでマッチした 部分より後ろの文字列です。 最後のマッチが失敗していた場合には nil となります。

...nil となります。

Regexp.last_match.post_match と同じです。

この変数はローカルスコープかつスレッドローカル、読み取り専用です。
Ruby起動時の初期値は nil です。

//emlist[例][ruby]{
str = '<p><a href="http://example.com">example.com</a></p>'
i...
...f %r[<a href="(.*?)">(.*?)</a>] =~ str
p $'
end
#=> "</p>"
//}...