ライブラリ
- ビルトイン (679)
- abbrev (24)
-
json
/ add / regexp (24) -
minitest
/ spec (2) -
minitest
/ unit (1) - optparse (24)
-
rdoc
/ parser (12) - readline (12)
- scanf (12)
- strscan (120)
- uri (24)
-
webrick
/ httputils (24)
クラス
- Array (12)
- Module (1)
- NilClass (7)
- Object (34)
- OptionParser (24)
-
RDoc
:: Options (12) -
RDoc
:: Parser (12) - Regexp (237)
- String (273)
- StringScanner (120)
- Symbol (129)
モジュール
- Abbrev (12)
- Kernel (36)
-
MiniTest
:: Assertions (1) - Readline (12)
- URI (24)
-
WEBrick
:: HTTPUtils (24)
キーワード
- !~ (12)
-
$ -F (12) -
$ ; (12) -
1
. 6 . 8から1 . 8 . 0への変更点(まとめ) (12) - == (12)
- === (24)
- =~ (28)
- FIXEDENCODING (12)
- Marshal フォーマット (12)
-
NEWS for Ruby 3
. 0 . 0 (5) - Rubyで使われる記号の意味(正規表現の複雑な記号は除く) (12)
- Ruby用語集 (12)
- [] (132)
- []= (84)
- abbrev (24)
- accept (24)
-
assert
_ match (1) - check (12)
-
check
_ until (12) - compile (12)
-
completion
_ proc= (12) - encoding (12)
- eql? (12)
- escape (24)
-
escape
_ path (12) - exclude= (12)
- exist? (12)
-
infect
_ with _ assertions (1) - inspect (12)
-
json
_ create (12) -
last
_ match (24) - match (48)
- match? (39)
-
must
_ match (1) - new (12)
-
parse
_ files _ matching (12) - print (12)
- quote (12)
-
ruby 1
. 6 feature (12) - scan (12)
-
scan
_ full (12) -
scan
_ until (12) - scanf (12)
-
search
_ full (12) - skip (12)
-
skip
_ until (12) - slice (132)
-
to
_ json (12) -
to
_ s (12) - union (12)
- yaml (12)
- リテラル (11)
- 多言語化 (12)
検索結果
先頭5件
-
URI
. regexp -> Regexp (18216.0) -
URIにマッチする正規表現を返します。
...どうかは必要に応じて別途
検査してください。
このメソッドは Ruby 2.2 から obsolete です。
@param schemes マッチさせたいスキームを、文字列の配列として与えます。
例:
require 'uri'
p URI.regexp =~ "http://www.ruby-lang.org/" #=> 0... -
URI
. regexp(schemes) -> Regexp (18216.0) -
URIにマッチする正規表現を返します。
...どうかは必要に応じて別途
検査してください。
このメソッドは Ruby 2.2 から obsolete です。
@param schemes マッチさせたいスキームを、文字列の配列として与えます。
例:
require 'uri'
p URI.regexp =~ "http://www.ruby-lang.org/" #=> 0... -
Regexp
. union(*pattern) -> Regexp (9289.0) -
引数として与えた pattern を選択 | で連結し、Regexp として返します。 結果の Regexp は与えた pattern のどれかにマッチする場合にマッチするものになります。
...引数として与えた pattern を選択 | で連結し、Regexp として返します。
結果の Regexp は与えた pattern のどれかにマッチする場合にマッチするものになります。
//emlist[][ruby]{
p Regexp.union(/a/, /b/, /c/) # => /(?-mix:a)|(?-mix:b)|(?-mix:c)/
//}......ay を与えても Regexp を生成します。
つまり、以下のように書くことができます。
//emlist[][ruby]{
arr = [/a/, /b/, /c/]
p Regexp.union(arr) # => /(?-mix:a)|(?-mix:b)|(?-mix:c)/
# 1.8.7 より前は、以下のように書く必要があった
p Regexp.union(*arr) # =>......ドが固定されている Regexp とコードが固定されていない Regexp を混ぜた場合、
結果の Regexp は固定されているコードに対応するものになります。
//emlist[][ruby]{
p Regexp.union(/a/e, /b/) # => /(?-mix:a)|(?-mix:b)/e
//}
@param pattern | で連結... -
Regexp
. compile(string , option = nil , code = nil) -> Regexp (9228.0) -
文字列 string をコンパイルして正規表現オブジェクトを生成して返します。
...製して返します。第二、第三引数は警告の上無視されます。
@param string 正規表現を文字列として与えます。
@param option Regexp::IGNORECASE, Regexp::MULTILINE,
Regexp::EXTENDED
の論理和を指定します。
Integer......ば
Regexp::IGNORECASE の指定と同じになります。
@param code "n", "N" が与えられた時には、生成された正規表現のエンコーディングは ASCII-8BIT になります。
それ以外の指定は警告を出力します。
@raise RegexpError......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_m... -
Regexp
. new(string , option = nil , code = nil) -> Regexp (9228.0) -
文字列 string をコンパイルして正規表現オブジェクトを生成して返します。
...製して返します。第二、第三引数は警告の上無視されます。
@param string 正規表現を文字列として与えます。
@param option Regexp::IGNORECASE, Regexp::MULTILINE,
Regexp::EXTENDED
の論理和を指定します。
Integer......ば
Regexp::IGNORECASE の指定と同じになります。
@param code "n", "N" が与えられた時には、生成された正規表現のエンコーディングは ASCII-8BIT になります。
それ以外の指定は警告を出力します。
@raise RegexpError......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_m... -
Regexp
. compile(string , option = nil) -> Regexp (9222.0) -
文字列 string をコンパイルして正規表現オブジェクトを生成して返します。
...数を複製して返します。第二引数は警告の上無視されます。
@param string 正規表現を文字列として与えます。
@param option Regexp::IGNORECASE, Regexp::MULTILINE,
Regexp::EXTENDED
の論理和を指定します。
Integer......false 以外)であれば
Regexp::IGNORECASE の指定と同じになります。
@raise RegexpError 正規表現のコンパイルに失敗した場合発生します。
//emlist[例][ruby]{
str = "This is Regexp"
t1 = Regexp.compile("this is regexp", Regexp::IGNORECASE)
t1.match(s......xp"
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
. new(string , option = nil) -> Regexp (9222.0) -
文字列 string をコンパイルして正規表現オブジェクトを生成して返します。
...数を複製して返します。第二引数は警告の上無視されます。
@param string 正規表現を文字列として与えます。
@param option Regexp::IGNORECASE, Regexp::MULTILINE,
Regexp::EXTENDED
の論理和を指定します。
Integer......false 以外)であれば
Regexp::IGNORECASE の指定と同じになります。
@raise RegexpError 正規表現のコンパイルに失敗した場合発生します。
//emlist[例][ruby]{
str = "This is Regexp"
t1 = Regexp.compile("this is regexp", Regexp::IGNORECASE)
t1.match(s......xp"
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
. json _ create(hash) -> Regexp (9107.0) -
JSON のオブジェクトから Ruby のオブジェクトを生成して返します。
...JSON のオブジェクトから Ruby のオブジェクトを生成して返します。
@param hash 適切なキーを持つハッシュを指定します。... -
Regexp
. last _ match(nth) -> String | nil (9077.0) -
整数 nth が 0 の場合、マッチした文字列を返します ($&)。それ以外では、nth 番目の括弧にマッチ した部分文字列を返します($1,$2,...)。 対応する括弧がない場合やマッチしなかった場合には nil を返し ます。
...)(.)/ =~ "ab"
p Regexp.last_match # => #<MatchData:0x4599e58>
p Regexp.last_match(0) # => "ab"
p Regexp.last_match(1) # => "a"
p Regexp.last_match(2) # => "b"
p Regexp.last_match(3) # => nil
//}
正規表現全体がマッチしなかった場合、引数なしの
Regexp.last_match は......。
//emlist[例][ruby]{
str = "This is Regexp"
/That is Regexp/ =~ str
p Regexp.last_match # => nil
begin
p Regexp.last_match[1] # 例外が発生する
rescue
puts $! # => undefined method `[]' for nil:NilClass
end
p Regexp.last_match(1) # => nil
//}
@param nth 整数を指定します。... -
Regexp
. last _ match -> MatchData (9042.0) -
カレントスコープで最後に行った正規表現マッチの MatchData オ ブジェクトを返します。このメソッドの呼び出しは $~ の参照と同じです。
...のメソッドの呼び出しは $~
の参照と同じです。
//emlist[例][ruby]{
/(.)(.)/ =~ "ab"
p Regexp.last_match # => #<MatchData:0x4599e58>
p Regexp.last_match[0] # => "ab"
p Regexp.last_match[1] # => "a"
p Regexp.last_match[2] # => "b"
p Regexp.last_match[3] # => nil
//}... -
Regexp
# match(str , pos = 0) -> MatchData | nil (9030.0) -
指定された文字列 str に対して位置 pos から自身が表す正規表現によるマッ チングを行います。マッチした場合には結果を MatchData オブジェクトで返し ます。 マッチしなかった場合 nil を返します。
...# => ["oo"]
//}
@param str 文字列を指定します。str との正規表現マッチを行います。
@param pos 整数を指定します。マッチの開始位置を pos から行うよう制御できます(pos のデフォルト値は 0)。
//emlist[例][ruby]{
reg = Regexp.new("foo")
if......に失敗した場合、
nil.captures を呼び出そうとして例外 NoMethodError が発生して
しまいます。
//emlist[例][ruby]{
foo, bar, baz = /(foo)(bar)(baz)/.match("foobar").captures
# => -:1: undefined method `captures' for nil:NilClass (NoMethodError)
//}
@see Regexp#match?...