種類
- インスタンスメソッド (187)
- 特異メソッド (77)
- 定数 (55)
ライブラリ
- ビルトイン (308)
-
json
/ add / regexp (11)
キーワード
- == (11)
- === (11)
- =~ (11)
- EXTENDED (11)
- FIXEDENCODING (11)
- IGNORECASE (11)
- MULTILINE (11)
- NOENCODING (11)
- compile (11)
- encoding (11)
- eql? (11)
- escape (11)
-
fixed
_ encoding? (11) - hash (11)
- inspect (11)
-
last
_ match (11) - match (22)
-
named
_ captures (11) - names (11)
- new (11)
- quote (11)
- source (11)
-
to
_ json (11) -
to
_ s (11) -
try
_ convert (11) - union (11)
- ~ (11)
検索結果
先頭5件
-
Regexp
. compile(string , option = nil , code = nil) -> Regexp (6301.0) -
文字列 string をコンパイルして正規表現オブジェクトを生成して返します。
...文字列 string をコンパイルして正規表現オブジェクトを生成して返します。
第一引数が正規表現であれば第一引数を複製して返します。第二、第三引数は警告の上無視されます。
@param string 正規表現を文字列として与えま......@param option Regexp::IGNORECASE, Regexp::MULTILINE,
Regexp::EXTENDED
の論理和を指定します。
Integer 以外であれば真偽値の指定として見なされ
、真(nil, false 以外)であれば
Regexp::IGNORECASE......ングは ASCII-8BIT になります。
それ以外の指定は警告を出力します。
@raise RegexpError 正規表現のコンパイルに失敗した場合発生します。
//emlist[例][ruby]{
str = "This is Regexp"
t1 = Regexp.compile("this is regexp", Regexp::IGNORECASE)
t1... -
Regexp
# inspect -> String (6225.0) -
Regexp#to_s より自然な文字列を返します。
...Regexp#to_s より自然な文字列を返します。
//emlist[例][ruby]{
p /^ugou.*?/i.to_s # => "(?i-mx:^ugou.*?)"
p /^ugou.*?/i.inspect # => "/^ugou.*?/i"
//}
@see Regexp#to_s... -
Regexp
# encoding -> Encoding (6201.0) -
正規表現オブジェクトのエンコーディングを表す Encoding オブジェクト を返します。
...正規表現オブジェクトのエンコーディングを表す Encoding オブジェクト
を返します。
@see d:spec/regexp#encoding... -
Regexp
:: NOENCODING -> Integer (6201.0) -
正規表現のマッチ時に文字列のエンコーディングを無視し、 バイト列としてマッチすることを意味します。
正規表現のマッチ時に文字列のエンコーディングを無視し、
バイト列としてマッチすることを意味します。
正規表現リテラルの n オプションに対応します。 -
Regexp
:: IGNORECASE -> Integer (6117.0) -
文字の大小の違いを無視します。 正規表現リテラルの //i オプションと同じです。
...文字の大小の違いを無視します。
正規表現リテラルの //i オプションと同じです。... -
Regexp
. union(*pattern) -> Regexp (6113.0) -
引数として与えた pattern を選択 | で連結し、Regexp として返します。 結果の Regexp は与えた pattern のどれかにマッチする場合にマッチするものになります。
...pattern を選択 | で連結し、Regexp として返します。
結果の Regexp は与えた pattern のどれかにマッチする場合にマッチするものになります。
//emlist[][ruby]{
p Regexp.union(/a/, /b/, /c/) # => /(?-mix:a)|(?-mix:b)|(?-mix:c)/
//}
引数を一つだけ与...... Regexp を生成します。
つまり、以下のように書くことができます。
//emlist[][ruby]{
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 に組み込まれます。
//emlist[][ruby]{
p Regexp.union("a", "?", "b") # =>... -
Regexp
# options -> Integer (6107.0) -
正規表現の生成時に指定されたオプションを返します。戻り値は、 Regexp::EXTENDED, Regexp::IGNORECASE, Regexp::MULTILINE, Regexp::FIXEDENCODING, Regexp::NOENCODING, の論理和です。
...正規表現の生成時に指定されたオプションを返します。戻り値は、
Regexp::EXTENDED, Regexp::IGNORECASE,
Regexp::MULTILINE,
Regexp::FIXEDENCODING,
Regexp::NOENCODING,
の論理和です。
これで得られるオプションには生成時に指定したもの以外の
オ......Regexp.new にこれらを
渡しても無視されます。
//emlist[例][ruby]{
p Regexp::IGNORECASE # => 1
p //i.options # => 1
p Regexp.new("foo", Regexp::IGNORECASE ).options # => 1
p Regexp.new("foo", Regexp::EXTENDED).options # => 2
p Regexp.new("foo", Regexp::IGNORECASE | Regexp:......ptions # => 3
p Regexp.new("foo", Regexp::MULTILINE).options # => 4
p Regexp.new("foo", Regexp::IGNORECASE | Regexp::MULTILINE ).options # => 5
p Regexp.new("foo", Regexp::MULTILINE | Regexp::EXTENDED).options # =>6
p Regexp.new("foo", Regexp::IGNORECASE | Regexp::MULTILINE | Regexp::EXTENDED).optio... -
Regexp
# fixed _ encoding? -> bool (6101.0) -
正規表現が任意の ASCII 互換エンコーディングとマッチ可能な時に false を返します。
...任意の ASCII 互換エンコーディングとマッチ可能な時に false を返します。
//emlist[例][ruby]{
# -*- coding:utf-8 -*-
r = /a/
r.fixed_encoding? # => false
r.encoding # => #<Encoding:US-ASCII>
r =~ "\u{6666}......force_encoding("euc-jp") # => 2
r =~ "abc".force_encoding("euc-jp") # => 0
r = /a/u
r.fixed_encoding? # => true
r.encoding # => #<Encoding:UTF-8>
r =~ "\u{6666} a" # => 2
begin
r =~ "......\xa1\xa2".force_encoding("euc-jp")
rescue => e
e.class # => Encoding::CompatibilityError
end
r =~ "abc".force_encoding("euc-jp") # => 0
r = /\u{6666}/
r.fixed_encoding? # => true
r.encoding... -
Regexp
:: FIXEDENCODING -> Integer (6101.0) -
正規表現が特定のエンコーディングの文字列にしかマッチしないことを意味します。
...正規表現が特定のエンコーディングの文字列にしかマッチしないことを意味します。
@see Regexp#fixed_encoding?... -
Regexp
:: MULTILINE -> Integer (6101.0) -
複数行モード。正規表現 "." が改行にマッチするようになります。 正規表現リテラルの //m オプションと同じです。
複数行モード。正規表現 "." が改行にマッチするようになります。
正規表現リテラルの //m オプションと同じです。