ライブラリ
- ビルトイン (555)
-
json
/ add / regexp (12) -
minitest
/ spec (2) -
minitest
/ unit (1) -
rdoc
/ parser (12) - scanf (12)
- strscan (120)
クラス
- MatchData (12)
- Module (1)
- Object (13)
-
RDoc
:: Options (24) -
RDoc
:: Parser (12) - Regexp (225)
- String (297)
- StringScanner (120)
- Symbol (33)
モジュール
キーワード
- == (12)
- === (12)
- =~ (12)
- [] (84)
- []= (84)
-
assert
_ match (1) - casefold? (12)
- check (12)
-
check
_ until (12) - encoding (12)
- eql? (12)
- exclude (12)
- exist? (12)
-
extra
_ accessors (12) -
fixed
_ encoding? (12) - hash (12)
-
infect
_ with _ assertions (1) - inspect (12)
- match (48)
- match? (39)
-
must
_ match (1) -
named
_ captures (12) - names (12)
-
parse
_ files _ matching (12) - scan (12)
-
scan
_ full (12) -
scan
_ until (12) - scanf (12)
-
search
_ full (12) - skip (12)
-
skip
_ until (12) - slice (84)
- slice! (24)
- source (12)
-
to
_ json (12) -
to
_ regexp (12) -
to
_ s (12) - ~ (12)
検索結果
先頭5件
-
MatchData
# regexp -> Regexp (30609.0) -
自身の元になった正規表現オブジェクトを返します。
...自身の元になった正規表現オブジェクトを返します。
//emlist[例][ruby]{
m = /a.*b/.match("abc")
m.regexp # => /a.*b/
//}... -
Object
# to _ regexp -> Regexp (18637.0) -
オブジェクトの Regexp への暗黙の変換が必要なときに内部で呼ばれます。 デフォルトでは定義されていません。
...オブジェクトの Regexp への暗黙の変換が必要なときに内部で呼ばれます。
デフォルトでは定義されていません。
説明のためここに記載してありますが、
このメソッドは実際には Object クラスには定義されていません。
必......ての場面で代置可能であるような、
* 正規表現そのものとみなせるようなもの
という厳しいものになっています。
//emlist[][ruby]{
class Foo
def to_regexp
/[\d]+/
end
end
it = Foo.new
p Regexp.union(/^at/, it) #=> /(?-mix:^at)|(?-mix:[\d]+)/
//}... -
Regexp
# options -> Integer (18461.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:.......options # => 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).opt... -
Regexp
# inspect -> String (18235.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 (18207.0) -
正規表現オブジェクトのエンコーディングを表す Encoding オブジェクト を返します。
...正規表現オブジェクトのエンコーディングを表す Encoding オブジェクト
を返します。
@see d:spec/regexp#encoding... -
Regexp
# named _ captures -> { String => [Integer] } (18201.0) -
正規表現に含まれる名前付きキャプチャ(named capture)の情報を Hash で返します。
...ャプチャ(named capture)の情報を
Hash で返します。
Hash のキーは名前付きキャプチャの名前で、値は
その名前に関連付けられたキャプチャの index のリストを返します。
//emlist[例][ruby]{
/(?<foo>.)(?<bar>.)/.named_captures
# => {"foo"=>[1], "......bar"=>[2]}
/(?<foo>.)(?<foo>.)/.named_captures
# => {"foo"=>[1, 2]}
# 名前付きキャプチャを持たないときは空の Hash を返します。
/(.)(.)/.named_captures
# => {}
//}... -
Regexp
# fixed _ encoding? -> bool (18101.0) -
正規表現が任意の ASCII 互換エンコーディングとマッチ可能な時に false を返します。
...ing:utf-8 -*-
r = /a/
r.fixed_encoding? # => false
r.encoding # => #<Encoding:US-ASCII>
r =~ "\u{6666} a" # => 2
r =~ "\xa1\xa2 a".force_encoding("euc-jp") # => 2
r =~ "abc".force_encoding("euc-jp"......ing? # => true
r.encoding # => #<Encoding:UTF-8>
r =~ "\u{6666} a" # => 2
begin
r =~ "\xa1\xa2".force_encoding("euc-jp")
rescue => e
e.class # => Encoding::Compa......orce_encoding("euc-jp") # => 0
r = /\u{6666}/
r.fixed_encoding? # => true
r.encoding # => #<Encoding:UTF-8>
r =~ "\u{6666} a" # => 0
begin
r =~ "\xa1\xa2".force_encoding("euc-jp")
rescue =... -
RDoc
:: Parser # parse _ files _ matching(regexp) -> () (15324.0) -
regexp で指定した正規表現にマッチするファイルを解析できるパーサとして、 自身を登録します。
...
regexp で指定した正規表現にマッチするファイルを解析できるパーサとして、
自身を登録します。
@param regexp 正規表現を指定します。
新しいパーサを作成する時に使用します。
例:
class RDoc::Parser::Xyz < RDoc::Parser
parse_f......iles_matching /\.xyz$/
...
end... -
Regexp
# =~(string) -> Integer | nil (15161.0) -
文字列 string との正規表現マッチを行います。マッチした場合、 マッチした位置のインデックスを返します(先頭は0)。マッチしなかった 場合、あるいは string が nil の場合には nil を返 します。
...ring との正規表現マッチを行います。マッチした場合、
マッチした位置のインデックスを返します(先頭は0)。マッチしなかった
場合、あるいは string が nil の場合には nil を返
します。
//emlist[例][ruby]{
p /foo/ =~ "foo" # => 0
p /f......=> 1
p /foo/ =~ "bar" # => nil
//}
組み込み変数 $~ もしくは Regexp.last_match にマッチに関する情報 MatchData が設定されます。
文字列のかわりにSymbolをマッチさせることができます。
@param string マッチ対象文字列
@raise TypeError string......が nil でも String オブジェクト
でも Symbol でもない場合発生します。
//emlist[例][ruby]{
p /foo/ =~ "foo" # => 0
p Regexp.last_match(0) # => "foo"
p /foo/ =~ "afoo" # => 1
p $~[0] # => "foo"
p /foo/ =~ "bar" # => nil
unl...