- $LAST_SUBMATCH_RESULT
- $^N
-
The text matched by the used group most-recently closed (i.e. the group with the rightmost closing parenthesis) of the last successful search pattern. This is subtly different from
$+
. For example in最近のマッチングに成功した検索パターンのうち、一番最近に閉じられた使われた グループ(つまり、一番右の閉じかっこのグループ)にマッチングしたテキスト。 これは
$+
とわずかに異なります。 例えば次のものは"ab" =~ /^((.)(.))$/
we have
次の結果になります
$1,$^N have the value "ab" $2 has the value "a" $3,$+ have the value "b"
This is primarily used inside
(?{...})
blocks for examining text recently matched. For example, to effectively capture text to a variable (in addition to$1
,$2
, etc.), replace(...)
withこれは主として最近マッチしたテキストを調べるために
(?{...})
ブロックの 中で使われます。 例えば、($1
,$2
などに加えて) テキストを変数に効率的に捕捉するには、(...)
を以下で置き換えます:(?:(...)(?{ $var = $^N }))
By setting and then using
$var
in this way relieves you from having to worry about exactly which numbered set of parentheses they are.$var
をこの方法で設定してから使うことで、かっこの組の番号について 気にしなくてすむようになります。This variable was added in Perl v5.8.0.
この変数は Perl v5.8.0 で追加されました。
Mnemonic: the (possibly) Nested parenthesis that most recently closed.
記憶法: もっとも最近閉じられた、(おそらく) ネストした (Nested) かっこ。