種類
- インスタンスメソッド (16)
- 文書 (11)
- 変数 (11)
ライブラリ
- ビルトイン (27)
モジュール
- Kernel (11)
キーワード
- match? (16)
- クラス/メソッドの定義 (11)
検索結果
先頭4件
-
Kernel
$ $ & -> String | nil (18214.0) -
現在のスコープで最後に成功した正規表現のパターンマッチでマッチした文字列です。 最後のマッチが失敗していた場合には nil となります。
...match[0] と同じです。
この変数はローカルスコープかつスレッドローカル、読み取り専用です。
Ruby起動時の初期値は nil です。
//emlist[例][ruby]{
str = '<p><a href="http://example.com">example.com</a></p>'
if %r[<a href="(.*?)">(.*?)</a>] =~ str
p $&... -
String
# match?(regexp , pos = 0) -> bool (15169.0) -
regexp.match?(self, pos) と同じです。 regexp が文字列の場合は、正規表現にコンパイルします。 詳しくは Regexp#match? を参照してください。
...match?(self, pos) と同じです。
regexp が文字列の場合は、正規表現にコンパイルします。
詳しくは Regexp#match? を参照してください。
//emlist[例][ruby]{
"Ruby".match?(/R.../) #=> true
"Ruby".match?(/R.../, 1) #=> false
"Ruby".match?(/P.../) #=> false
$&......#=> nil
//}
@see Regexp#match?, Symbol#match?... -
Symbol
# match?(regexp , pos = 0) -> bool (6187.0) -
regexp.match?(self, pos) と同じです。 regexp が文字列の場合は、正規表現にコンパイルします。 詳しくは Regexp#match? を参照してください。
...regexp.match?(self, pos) と同じです。
regexp が文字列の場合は、正規表現にコンパイルします。
詳しくは Regexp#match? を参照してください。
例:
:Ruby.match?(/R.../) # => true
:Ruby.match?('Ruby') # => true
:Ruby.match?('Ruby',1) # => false
:R......uby.match?('uby',1) # => true
:Ruby.match?(/P.../) # => false
$& # => nil
@see Regexp#match?, String#match?... -
クラス/メソッドの定義 (24.0)
-
クラス/メソッドの定義 * クラス/メソッドの定義: * class * singleton_class * module * method * operator * nest_method * eval_method * singleton_method * class_method * limit * 定義に関する操作: * alias * undef * defined
...に指定しても同じ)
class Foo
def bar
end
end
# 間違ったスーパークラスを指定するとエラー
class Foo < String
end
# => superclass mismatch for class Foo (TypeError)
//}
クラス定義式の中は self がそのクラスであることと、
limitのデフォルトが......elf._val + other._val
end
end
//}
=== 定義に関する操作
====[a:alias] alias
//emlist[例][ruby]{
alias foo bar
alias :foo :bar
alias $MATCH $&
//}
文法:
alias 新メソッド名 旧メソッド名
alias 新グローバル変数名 旧グローバル変数名
メ......行いませんがローカル変数は定義されます。
//emlist[][ruby]{
/(.)/ =~ "foo"
defined? $& # => "global-variable"
defined? $1 # => "global-variable"
defined? $2 # => nil
//}
$&, $1, $2, などは直前のマッチの結果値が設定された場合だけ真を返します。
//...