3件ヒット
[1-3件を表示]
(0.094秒)
別のキーワード
クラス
- MatchData (2)
- StringScanner (1)
検索結果
先頭3件
-
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