ライブラリ
- ビルトイン (23)
-
json
/ add / core (2) -
syck
/ rubytypes (4) -
yaml
/ rubytypes (2)
キーワード
- compile (3)
- escape (3)
-
json
_ create (2) -
last
_ match (6) - new (3)
- quote (3)
-
try
_ convert (2) - union (3)
-
yaml
_ new (3) -
yaml
_ tag _ subclasses? (3)
検索結果
先頭5件
-
Regexp
. compile(string , option = nil , code = nil) -> Regexp (2) -
文字列 string をコンパイルして正規表現オブジェクトを生成して返します。
...@param option Regexp::IGNORECASE, Regexp::MULTILINE,
Regexp::EXTENDED
の論理和を指定します。
Fixnum 以外であれば真偽値の指定として見なされ
、真(nil, false 以外)であれば
Regexp::IGNORECASE...... RegexpError 正規表現のコンパイルに失敗した場合発生します。
str = "This is Regexp"
t1 = Regexp.compile("this is regexp", Regexp::IGNORECASE)
t1.match(str)
puts $~ #=> This is Regexp
t2 = Regexp.compile('
this # ここは使用されない
\ is
\ regexp......# ここも使用されない
', Regexp::EXTENDED | Regexp::IGNORECASE)
t2.match(str)
puts Regexp.last_match #=> This is Regexp
str = "ふるいけや\nかわずとびこむ\nみずのおと"
t2 = Regexp.compile("ふる.*?と", Regexp::MULTILINE)
puts t2.match(str)[0] #=> ふる... -
Regexp
. escape(string) -> String (2) -
string の中で正規表現において特別な意味を持つ文字の直前にエ スケープ文字(バックスラッシュ)を挿入した文字列を返します。
...て特別な意味を持つ文字の直前にエ
スケープ文字(バックスラッシュ)を挿入した文字列を返します。
@param string 正規表現において特別な意味をもつ文字をもつ文字列を指定します。
rp = Regexp.escape("$bc^")
puts rp #=> \$bc\^... -
Regexp
. escape(string , kcode = $ KCODE) -> String (2) -
string の中で正規表現において特別な意味を持つ文字の直前にエ スケープ文字(バックスラッシュ)を挿入した文字列を返します。
...います。
@param string 正規表現において特別な意味をもつ文字をもつ文字列を指定します。
@param kcode 文字コードを文字列で指定します。文字コードの指定は $KCODE と同様に行います。
rp = Regexp.escape("$bc^")
puts rp #=> \$bc\^... -
Regexp
. json _ create(hash) -> Regexp (2) -
JSON のオブジェクトから Ruby のオブジェクトを生成して返します。
JSON のオブジェクトから Ruby のオブジェクトを生成して返します。
@param hash 適切なキーを持つハッシュを指定します。 -
Regexp
. last _ match -> MatchData (2) -
カレントスコープで最後に行った正規表現マッチの MatchData オ ブジェクトを返します。このメソッドの呼び出しは $~ の参照と同じです。
...ます。このメソッドの呼び出しは $~
の参照と同じです。
/(.)(.)/ =~ "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(nth) -> String | nil (2) -
整数 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......(1) は nil を返します。
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
. new(string , option = nil , code = nil) -> Regexp (2) -
文字列 string をコンパイルして正規表現オブジェクトを生成して返します。
...@param option Regexp::IGNORECASE, Regexp::MULTILINE,
Regexp::EXTENDED
の論理和を指定します。
Fixnum 以外であれば真偽値の指定として見なされ
、真(nil, false 以外)であれば
Regexp::IGNORECASE...... RegexpError 正規表現のコンパイルに失敗した場合発生します。
str = "This is Regexp"
t1 = Regexp.compile("this is regexp", Regexp::IGNORECASE)
t1.match(str)
puts $~ #=> This is Regexp
t2 = Regexp.compile('
this # ここは使用されない
\ is
\ regexp......# ここも使用されない
', Regexp::EXTENDED | Regexp::IGNORECASE)
t2.match(str)
puts Regexp.last_match #=> This is Regexp
str = "ふるいけや\nかわずとびこむ\nみずのおと"
t2 = Regexp.compile("ふる.*?と", Regexp::MULTILINE)
puts t2.match(str)[0] #=> ふる... -
Regexp
. quote(string) -> String (2) -
string の中で正規表現において特別な意味を持つ文字の直前にエ スケープ文字(バックスラッシュ)を挿入した文字列を返します。
...て特別な意味を持つ文字の直前にエ
スケープ文字(バックスラッシュ)を挿入した文字列を返します。
@param string 正規表現において特別な意味をもつ文字をもつ文字列を指定します。
rp = Regexp.escape("$bc^")
puts rp #=> \$bc\^... -
Regexp
. quote(string , kcode = $ KCODE) -> String (2) -
string の中で正規表現において特別な意味を持つ文字の直前にエ スケープ文字(バックスラッシュ)を挿入した文字列を返します。
...います。
@param string 正規表現において特別な意味をもつ文字をもつ文字列を指定します。
@param kcode 文字コードを文字列で指定します。文字コードの指定は $KCODE と同様に行います。
rp = Regexp.escape("$bc^")
puts rp #=> \$bc\^... -
Regexp
. try _ convert(obj) -> Regexp | nil (2) -
obj を to_regexp メソッドで Regexp オブジェクトに変換しようと 試みます。
...obj を to_regexp メソッドで Regexp オブジェクトに変換しようと
試みます。
変換に成功した場合はそれを返し、失敗時には nil を返します。
Regexp.try_convert(/re/) # => /re/
Regexp.try_convert("re") # => nil... -
Regexp
. union(*pattern) -> Regexp (2) -
引数として与えた pattern を選択 | で連結し、Regexp として返します。 結果の Regexp は与えた pattern のどれかにマッチする場合にマッチするものになります。
...し、Regexp として返します。
結果の Regexp は与えた pattern のどれかにマッチする場合にマッチするものになります。
p Regexp.union(/a/, /b/, /c/) #=> /(?-mix:a)|(?-mix:b)|(?-mix:c)/
引数を一つだけ与える場合は、Array を与えても Regexp を......ができます。
arr = [/a/, /b/, /c/]
p Regexp.union(arr) #=> /(?-mix:a)|(?-mix:b)|(?-mix:c)/
# 1.8.7 より前は、以下のように書く必要があった
p Regexp.union(*arr) #=> /(?-mix:a)|(?-mix:b)|(?-mix:c)/
pattern は Regexp または String で与えます。
String で与......結果の Regexp に組み込まれます。
p Regexp.union("a", "?", "b") # => /a|\?|b/
p Regexp.union(/a/, "*") # => /(?-mix:a)|\*/
引数をひとつも与えなかった場合、決してマッチしない Regexp を返します。
p Regexp.union() # => /(?!)/
結果の Regexp が対... -
Regexp
. yaml _ new(klass , tag , val) (2) -
ライブラリ内部で使用します。
ライブラリ内部で使用します。 -
Regexp
. yaml _ tag _ subclasses? -> true (2) -
常に true を返します。
常に true を返します。
ライブラリ内部で使用します。
