るりまサーチ

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

別のキーワード

  1. uri regexp
  2. _builtin regexp
  3. regexp match
  4. etc sc_regexp
  5. regexp last_match

種類

ライブラリ

クラス

モジュール

キーワード

検索結果

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

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

...@param option Regexp::IGNORECASE, Regexp::MULTILINE,
Regexp
::EXTENDED
の論理和を指定します。
Integer 以外であれば真偽値の指定として見なされ
、真(nil, false 以外)であれば
Regexp
::IGNORECASE...
...を出力します。

@raise RegexpError 正規表現のコンパイルに失敗した場合発生します。

//emlist[例][ruby]{
str = "This 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_match # => "This is Regexp"

str = "ふるいけや\nかわずとびこむ\nみずのおと"
t2 = Regexp.compile("ふる.*?と", Regexp::MULTILINE)
p t2.match(str)...

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

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

...@param option Regexp::IGNORECASE, Regexp::MULTILINE,
Regexp
::EXTENDED
の論理和を指定します。
Integer 以外であれば真偽値の指定として見なされ
、真(nil, false 以外)であれば
Regexp
::IGNORECASE...
...を出力します。

@raise RegexpError 正規表現のコンパイルに失敗した場合発生します。

//emlist[例][ruby]{
str = "This 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_match # => "This is Regexp"

str = "ふるいけや\nかわずとびこむ\nみずのおと"
t2 = Regexp.compile("ふる.*?と", Regexp::MULTILINE)
p t2.match(str)...

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

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

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

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

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

この変数はローカルスコープかつスレッドローカルです。
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"
//}...

ruby 1.6 feature (168.0)

ruby 1.6 feature ruby version 1.6 は安定版です。この版での変更はバグ修正がメイン になります。

...: 2002-05-02 Regexp.quote

# はバックスラッシュクォートするようになりました。これは、quote した
正規表現を //x に正しく埋め込めるようにするためです。
((<ruby-bugs-ja:PR#231>))

p Regexp.quote("#")

p /a#{Regexp.quote("#")}b...
...定でない場合、SecurityError 例外が発生する
ようになりました。

: 2002-04-26: Regexp.quote

((<ruby-bugs-ja:PR#231>))

p Regexp.quote("\t")

p /a#{Regexp.quote("\t")}b/x =~ "ab"

=> -:3: warning: ambiguous first argument; make sure
ruby 1....
...1
1.1
:
1.9

: 2002-04-01: ((<組み込み変数/$~>))

$~
に nil を代入できないバグが修正されました。((<ruby-dev:16697>))

/foo/ =~ "foo"
p $~
$~
= nil
p $~
=> ruby 1.6.7 (2002-03-01) [i586-linux]
#<MatchData:0x401b1be4>...