るりまサーチ (Ruby 2.4.0)

最速Rubyリファレンスマニュアル検索!
3件ヒット [1-3件を表示] (0.094秒)

別のキーワード

  1. strscan pre_match
  2. matchdata pre_match
  3. _builtin pre_match
  4. stringscanner pre_match
  5. pre_match strscan

ライブラリ

クラス

検索結果

MatchData#pre_match -> String (90625.0)

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

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

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

@see MatchData#post_match

StringScanner#pre_match -> String | nil (72715.0)

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

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

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

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

MatchData#post_match -> String (36322.0)

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

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

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

@see MatchData#pre_match