検索結果
先頭5件
-
Kernel
$ $ MATCH -> String | nil (6209.0) -
$& の別名
...$& の別名
require "English"
str = 'hoge,foo,bar,hee,hoo'
/(foo|bar)/ =~ str
p $MATCH #=> "foo"... -
Kernel
$ $ LAST _ PAREN _ MATCH -> String | nil (6203.0) -
$+ の別名
$+ の別名
require "English"
r1 = Regexp.compile("<img src=(http:.+?)>")
r2 = Regexp.compile("<a href=(http|ftp).+?>(.+?)</a>")
while line = DATA.gets
[ r1, r2 ].each {|rep|
rep =~ line
p $+
}
end
__END__
<tr> <td><img src=http://localhost/a.jpg></td> <td>ikkou</td>... -
Kernel
$ $ POSTMATCH -> String | nil (6202.0) -
$' の別名
...$' の別名
require "English"
str = 'hoge,foo,bar,hee,hoo'
/foo/ =~ str
p $POSTMATCH #=> ",bar,hee,hoo"... -
Kernel
$ $ PREMATCH -> String | nil (6202.0) -
$` の別名
...$` の別名
require "English"
str = 'hoge,foo,bar,hee,hoo'
/foo/ =~ str
p $PREMATCH #=> "hoge,"... -
Kernel
. # gsub(pattern) {|matched| . . . } -> String (209.0) -
$_.gsub とほぼ同じですが、置換が発生したときは、$_の内容を置き換える点が異なります。 コマンドラインオプションで -p または -n を指定した時のみ定義されます。
...規表現。
文字列を指定した場合は全く同じ文字列にだけマッチする
@param replace pattern で指定した文字列と置き換える文字列
//emlist[例][ruby]{
$_ # => "test\n"
gsub(/es/, '!!') # => "t!!t\n"
//}
@see String#gsub,$_... -
Kernel
. # sub(pattern) {|matched| . . . } -> String (209.0) -
$_.sub とほぼ同じですが、置換が発生したときは、$_の内容を置き換える点が異なります。 コマンドラインオプションで -p または -n を指定した時のみ定義されます。
...現。
文字列を指定した場合は全く同じ文字列にだけマッチする
@param replace pattern で指定した文字列と置き換える文字列
//emlist[例][ruby]{
$_ # => "testtest\n"
sub(/es/, '!!') # => "t!!ttest\n"
//}
@see String#sub,$_... -
Kernel
$ $ 1 -> String | nil (124.0) -
最後に成功したパターンマッチで n 番目の括弧にマッチした値が格納されます。 該当する括弧がなければ nil が入っています。(覚え方: \数字 のようなもの)
...います。(覚え方: \数字 のようなもの)
番号 n はいくらでも大きな正整数を利用できます。
Regexp.last_match(1),
Regexp.last_match(2), ... と同じ。
これらの変数はローカルスコープかつスレッドローカル、読み取り専用です。
//emlis... -
Kernel
$ $ 10 -> String | nil (124.0) -
最後に成功したパターンマッチで n 番目の括弧にマッチした値が格納されます。 該当する括弧がなければ nil が入っています。(覚え方: \数字 のようなもの)
...います。(覚え方: \数字 のようなもの)
番号 n はいくらでも大きな正整数を利用できます。
Regexp.last_match(1),
Regexp.last_match(2), ... と同じ。
これらの変数はローカルスコープかつスレッドローカル、読み取り専用です。
//emlis... -
Kernel
$ $ 11 -> String | nil (124.0) -
最後に成功したパターンマッチで n 番目の括弧にマッチした値が格納されます。 該当する括弧がなければ nil が入っています。(覚え方: \数字 のようなもの)
...います。(覚え方: \数字 のようなもの)
番号 n はいくらでも大きな正整数を利用できます。
Regexp.last_match(1),
Regexp.last_match(2), ... と同じ。
これらの変数はローカルスコープかつスレッドローカル、読み取り専用です。
//emlis... -
Kernel
$ $ 2 -> String | nil (124.0) -
最後に成功したパターンマッチで n 番目の括弧にマッチした値が格納されます。 該当する括弧がなければ nil が入っています。(覚え方: \数字 のようなもの)
...います。(覚え方: \数字 のようなもの)
番号 n はいくらでも大きな正整数を利用できます。
Regexp.last_match(1),
Regexp.last_match(2), ... と同じ。
これらの変数はローカルスコープかつスレッドローカル、読み取り専用です。
//emlis...