別のキーワード
種類
- インスタンスメソッド (18)
- 特異メソッド (9)
ライブラリ
- ビルトイン (22)
- eregex (2)
-
syck
/ rubytypes (2) -
yaml
/ rubytypes (1)
検索結果
先頭5件
-
Regexp
. new(string , option = nil , code = nil) -> Regexp (15102) -
文字列 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
. yaml _ new(klass , tag , val) (6102) -
ライブラリ内部で使用します。
ライブラリ内部で使用します。 -
Regexp
# options -> Integer (49) -
正規表現の生成時に指定されたオプションを返します。戻り値は、 Regexp::EXTENDED, Regexp::IGNORECASE, Regexp::MULTILINE, Regexp::FIXEDENCODING, の論理和です。
...は、
Regexp::EXTENDED, Regexp::IGNORECASE,
Regexp::MULTILINE,
の論理和です。
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::IGNOREC......tions #=> 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).op......正規表現の生成時に指定されたオプションを返します。戻り値は、
Regexp::EXTENDED, Regexp::IGNORECASE,
Regexp::MULTILINE,
Regexp::FIXEDENCODING,
の論理和です。
これで得られるオプションには生成時に指定したもの以外の
オプションを含......で、Regexp.new にこれらを
渡しても無視されます。
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::EXTEND......正規表現の生成時に指定されたオプションを返します。戻り値は、
Regexp::EXTENDED, Regexp::IGNORECASE,
Regexp::MULTILINE,
Regexp::FIXEDENCODING,
Regexp::NOENCODING,
の論理和です。
これで得られるオプションには生成時に指定したもの以外の
オ... -
Regexp
# &(other) -> RedAnd (17) -
RegAnd.new(self, other) を返します。
...RegAnd.new(self, other) を返します。
@param other 正規表現オブジェクト。... -
Regexp
# |(other) -> RegOr (17) -
RegOr.new(self, other) を返します。
...RegOr.new(self, other) を返します。
@param other 正規表現オブジェクト。... -
Regexp
# casefold? -> bool (13) -
正規表現が大文字小文字の判定をしないようにコンパイルされている時、 真を返します。
...小文字の判定をしないようにコンパイルされている時、
真を返します。
reg = Regexp.new("foobar", Regexp::IGNORECASE)
p reg.casefold? #=> true
reg = Regexp.new("hogehoge")
p reg.casefold? #=> false... -
Regexp
# kcode -> String | nil (13) -
その正規表現が対応するようにコンパイルされている文字コードを $KCODE と同じ形式で返します。もし、正規表現が固定 コードに対してコンパイルされていない(マッチ時点での $KCODE の値を用いる)場合には、nil を返します。
...し、正規表現が固定
コードに対してコンパイルされていない(マッチ時点での $KCODE
の値を用いる)場合には、nil を返します。
reg = Regexp.new("hogehoge", nil, "u")
p reg.kcode #=> "utf8"
reg = Regexp.new("hogehoge", nil)
p reg.kcode #=> "nil"... -
Regexp
# ==(other) -> bool (7) -
otherが同じパターン、オプション、文字コードの正規表現であったらtrueを返します。
...規表現であったらtrueを返します。
@param other 正規表現を指定します。
p /^eee$/ == /~eee$/x #=> false
p /^eee$/ == /~eee$/i #=> false
p /^eee$/e == /~eee$/u #=> false
p /^eee$/ == Regexp.new("^eee$") #=> true
p /^eee$/.eql?(/^eee$/) #=> true... -
Regexp
# eql?(other) -> bool (7) -
otherが同じパターン、オプション、文字コードの正規表現であったらtrueを返します。
...規表現であったらtrueを返します。
@param other 正規表現を指定します。
p /^eee$/ == /~eee$/x #=> false
p /^eee$/ == /~eee$/i #=> false
p /^eee$/e == /~eee$/u #=> false
p /^eee$/ == Regexp.new("^eee$") #=> true
p /^eee$/.eql?(/^eee$/) #=> true... -
Regexp
# match(str) -> MatchData | nil (7) -
指定された文字列 str に対して 自身が表す正規表現によるマッチングを行います。マッチした場合には結果を MatchData オブジェクトで返します。 マッチしなかった場合 nil を返します。
...場合 nil を返します。
@param str 文字列を指定します。str との正規表現マッチを行います。
使用例
reg = Regexp.new("foo")
if reg.match("foobar")
print "match\n" #=> match
end
p reg.match("foobar") #=> #<MatchData:0x29403fc>
p reg.match("bar")... -
Regexp
# match(str , pos = 0) -> MatchData | nil (7) -
指定された文字列 str に対して 位置 pos から 自身が表す正規表現によるマッチングを行います。マッチした場合には結果を MatchData オブジェクトで返します。 マッチしなかった場合 nil を返します。
...を指定します。マッチの開始位置を pos から行うよう制御できます(pos のデフォルト値は 0)。
使用例
reg = Regexp.new("foo")
if reg.match("foobar")
print "match\n" #=> match
end
p reg.match("foobar") #=> #<MatchData:0x29403fc>
p reg.match("bar")... -
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] #=> ふる...
