るりまサーチ (Ruby 2.4.0)

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

別のキーワード

  1. _builtin to_h
  2. struct to_h
  3. array to_h
  4. hash to_h
  5. ostruct to_h

ライブラリ

クラス

検索結果

StringScanner#post_match -> String | nil (82087.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...

MatchData#post_match -> String (72925.0)

マッチした部分より後ろの文字列を返します($'と同じ)。

マッチした部分より後ろの文字列を返します($'と同じ)。

//emlist[例][ruby]{
/(bar)(BAZ)?/ =~ "foobarbaz"
p $~.post_match # => "baz"
//}

@see MatchData#pre_match

MatchData#pre_match -> String (18622.0)

マッチした部分より前の文字列を返します($`と同じ)。

マッチした部分より前の文字列を返します($`と同じ)。

//emlist[例][ruby]{
/(bar)(BAZ)?/ =~ "foobarbaz"
p $~.pre_match # => "foo"
//}

@see MatchData#post_match