るりまサーチ

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

別のキーワード

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

ライブラリ

クラス

モジュール

検索結果

<< 1 2 3 ... > >>

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?...
<< 1 2 3 ... > >>