るりまサーチ

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

別のキーワード

  1. openssl p
  2. openssl p=
  3. fileutils mkdir_p
  4. dh p
  5. dh p=

クラス

モジュール

キーワード

検索結果

Kernel$$~ -> MatchData | nil (18121.0)

現在のスコープで最後に成功したマッチに関する MatchDataオブジェクトです。 Regexp.last_match の別名です。

...マッチに関する MatchDataオブジェクトです。
Regexp.last_match の別名です。

このデータから n 番目のマッチ ($n) を取り出すためには $~[n] を使います。

この値に代入すると Regexp.last_match や、 $&, $1, $2, ... などの関連する組み込...
...ypeError が発生します。

この変数はローカルスコープかつスレッドローカルです。
Ruby起動時の初期値は nil です。

//emlist[例][ruby]{
str = '<p><a href="http://example.com">example.com</a></p>'
if %r[<a href="(.*?)">(.*?)</a>] =~ str
p
$~[1]
end
#=> "http:...
...//example.com"
//}...

Regexp.compile(string, option = nil, code = nil) -> Regexp (6126.0)

文字列 string をコンパイルして正規表現オブジェクトを生成して返します。

...して返します。第二、第三引数は警告の上無視されます。

@param string 正規表現を文字列として与えます。

@param option Regexp::IGNORECASE, Regexp::MULTILINE,
Regexp::EXTENDED
の論理和を指定します。
Integer...
...Regexp::IGNORECASE の指定と同じになります。

@param code "n", "N" が与えられた時には、生成された正規表現のエンコーディングは ASCII-8BIT になります。
それ以外の指定は警告を出力します。

@raise RegexpError 正規表...
...s is Regexp"
t1 = Regexp.compile("this is regexp", Regexp::IGNORECASE)
t1.match(str)
p
$~ # => "This is Regexp"

t2 = Regexp.compile('
this # ここは使用されない
\ is
\ regexp # ここも使用されない
', Regexp::EXTENDED | Regexp::IGNORECASE)
t2.match(str)
p
Regexp.last_matc...

Regexp.new(string, option = nil, code = nil) -> Regexp (3126.0)

文字列 string をコンパイルして正規表現オブジェクトを生成して返します。

...して返します。第二、第三引数は警告の上無視されます。

@param string 正規表現を文字列として与えます。

@param option Regexp::IGNORECASE, Regexp::MULTILINE,
Regexp::EXTENDED
の論理和を指定します。
Integer...
...Regexp::IGNORECASE の指定と同じになります。

@param code "n", "N" が与えられた時には、生成された正規表現のエンコーディングは ASCII-8BIT になります。
それ以外の指定は警告を出力します。

@raise RegexpError 正規表...
...s is Regexp"
t1 = Regexp.compile("this is regexp", Regexp::IGNORECASE)
t1.match(str)
p
$~ # => "This is Regexp"

t2 = Regexp.compile('
this # ここは使用されない
\ is
\ regexp # ここも使用されない
', Regexp::EXTENDED | Regexp::IGNORECASE)
t2.match(str)
p
Regexp.last_matc...

String#byterindex(pattern, offset = self.bytesize) -> Integer | nil (132.0)

文字列のバイト単位のインデックス offset から左に向かって pattern を探索します。 最初に見つかった部分文字列の左端のバイト単位のインデックスを返します。 見つからなければ nil を返します。

...のインデックス offset から左に向かって pattern を探索します。
最初に見つかった部分文字列の左端のバイト単位のインデックスを返します。
見つからなければ nil を返します。

引数 pattern は探索する部分文字列または正規...
...[String#byteindex の場合][ruby]{
p
"stringstring".byteindex("ing", 1) # => 3
# ing # ここから探索を始める
# ing
# ing # 右にずらしていってここで見つかる
//}

//emlist[String#byterindex の場合][ruby]{
p
"stringstring".byterindex("ing", -...
...探索を始める
# ing
# ing # 左にずらしていってここで見つかる
//}

@param pattern 探索する部分文字列または正規表現
@param offset 探索を始めるバイト単位のインデックス

//emlist[例][ruby]{
'foo'.byterindex('f') # =...

MatchData#to_s -> String (20.0)

マッチした文字列全体を返します。

...マッチした文字列全体を返します。

//emlist[例][ruby]{
/bar/ =~ "foobarbaz"
p
$~ # => #<MatchData:0x401b1be4>
p
$~.to_s # => "bar"
//}...

絞り込み条件を変える