るりまサーチ

最速Rubyリファレンスマニュアル検索!
97件ヒット [1-97件を表示] (0.015秒)
トップページ > クエリ:Regexp[x] > クエリ:compile[x]

別のキーワード

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

ライブラリ

クラス

モジュール

検索結果

Regexp.compile(string, option = nil, code = nil) -> Regexp (39323.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 (24223.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#~ -> Integer | nil (21012.0)

変数 $_ の値との間でのマッチをとります。

..."

if /foo/
puts "match"
else
puts "no match"
end
# => no match
# ただし、警告がでる。warning: regex literal in condition

reg = Regexp.compile("foo")

if ~ reg
puts "match"
else
puts "no match"
end
# => no match

if reg
puts "match"
else
puts "no match"
end
# => match
# re...

RegexpError (6024.0)

正規表現のコンパイルに失敗したときに発生します。

...正規表現のコンパイルに失敗したときに発生します。

例:

$ ruby -e 'Regexp.compile("*")'
-e:1:in `initialize': target of repeat operator is not specified: /*/ (RegexpError)
from -e:1:in `Regexp#compile'
from -e:1...

正規表現 (3162.0)

正規表現 * metachar * expansion * char * anychar * string * str * quantifier * capture * grouping * subexp * selector * anchor * cond * option * encoding * comment * free_format_mode * absenceop * list * specialvar * references

...文字列中のどの場所であるかを知ることができます。

//emlist[][ruby]{
/pat/
%r{pat}
//}

などの正規表現リテラルや Regexp.new などで正規表現
オブジェクトを得ることができます。


===[a:metachar] メタ文字列とリテラル、メタ文字と...
...er}/.match("43+291")
# => #<MatchData "43+291" 1:"43" 2:"+" 3:"291">
//}

埋め込む文字列をリテラルとして認識させたい場合は Regexp.quote を
使います。

===[a:char] 文字
正規表現内では、「\」の後に文字列を置くことで、
ある特定の文字を表...
...//emlist[][ruby]{
r = Regexp.compile(<<'__REGEXP__'.strip, Regexp::EXTENDED)
(?<element> \g<stag> \g<content>* \g<etag> ){0}
(?<stag> < \g<name> \s* > ){0}
(?<name> [a-zA-Z_:]+ ){0}
(?<content> [^<&]+ (\g<element> | [^<&]+)* ){0}
(?<etag> </ \k<name+1> >){0}
\g<element>
__REGEXP__
r.match('<foo>f<ba...

絞り込み条件を変える

1.6.8から1.8.0への変更点(まとめ) (186.0)

1.6.8から1.8.0への変更点(まとめ) * ((<1.6.8から1.8.0への変更点(まとめ)/インタプリタの変更>)) * ((<1.6.8から1.8.0への変更点(まとめ)/追加されたクラス/モジュール>)) * ((<1.6.8から1.8.0への変更点(まとめ)/追加されたメソッド>)) * ((<1.6.8から1.8.0への変更点(まとめ)/追加された定数>)) * ((<1.6.8から1.8.0への変更点(まとめ)/拡張されたクラス/メソッド(互換性のある変更)>)) * ((<1.6.8から1.8.0への変更点(まとめ)/変更されたクラス/メソッド(互換性のない変更)>)) * ((<1.6.8から1.8.0への変更点(まとめ)/文法の変更>)) * ((<1.6.8から1.8.0への変更点(まとめ)/正規表現>)) * ((<1.6.8から1.8.0への変更点(まとめ)/Marshal>)) * ((<1.6.8から1.8.0への変更点(まとめ)/Windows 対応>)) * ((<1.6.8から1.8.0への変更点(まとめ)/廃止された(される予定の)機能>)) * ((<1.6.8から1.8.0への変更点(まとめ)/ライブラリ>)) * ((<1.6.8から1.8.0への変更点(まとめ)/拡張ライブラリAPI>)) * ((<1.6.8から1.8.0への変更点(まとめ)/バグ修正>)) * ((<1.6.8から1.8.0への変更点(まとめ)/サポートプラットフォームの追加>))

...== Regexp

: ((<Regexp#to_s|Regexp/to_s>)) [new]

追加。((<ruby-dev:16909>))

これにより、
re1 = /hogehoge/i
re2 = /fugafuga/
re3 = / #{re1} | #{re2} /x
などと正規表現オブジェクトを正規表現に埋め込めるようになりました。

: ((<Regexp#o...
...ptions|Regexp/options>)) [new]
追加

=== Socket

: ((<Socket/Socket.pack_sockaddr_in>)) [new]
: ((<Socket/Socket.unpack_sockaddr_in>)) [new]

追加。ソケットアドレス構造体(INET domain)のpack/unpack。

: ((<Socket/Socket.pack_sockaddr_un>)) [new]
: (...
...(*regexp*))>)) [compat]

pattern として正規表現でなく文字列を指定したとき、それを正規表現にコ
ンパイルせず文字列そのものをパターンとして扱うようになりました。(よ
り正確には、Regexp.compile(arg) でなく
Regexp
.compile(R...

ruby 1.6 feature (108.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....
...#{..} の中などで不完全な部分がありました。
((<ruby-list:34478>))

#! ruby -Ks
p a = "#{"表"}"
=> -:1: compile error in string expansion (SyntaxError)
-:1: unterminated string meets end of file
ruby 1.6.7 (2002-03-15) [i586-linux]...

Kernel$$LAST_PAREN_MATCH -> String | nil (24.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>ikko...

NEWS for Ruby 2.3.0 (24.0)

NEWS for Ruby 2.3.0 このドキュメントは前回リリース以降のバグ修正を除くユーザーに影響のある機能の変更のリストです。

...hese calls.
11569

* Queue (Thread::Queue)
* 終了を通知するために Queue#close(Thread::Queue#close) を追加
10600

* Regexp/String: Unicode のバージョンを 7.0.0 から 8.0.0 に更新

* RubyVM::InstructionSequence
* 実験的な機能としてiseqロー...
...11558

* rb_autoload() は非推奨になりました。rb_funcall() を使ってください。
11664

* rb_compile_error_with_enc(), rb_compile_error(), rb_compile_bug() が非推奨になりました。
これらの関数は公開されていますが、内部利用のためな...