ライブラリ
- English (12)
- ビルトイン (375)
- csv (24)
-
minitest
/ spec (1) -
minitest
/ unit (1) - optparse (24)
-
rdoc
/ parser (12) - strscan (60)
クラス
- CSV (24)
- MatchData (24)
- Object (1)
- OptionParser (24)
-
RDoc
:: Parser (12) - Regexp (105)
- String (33)
- StringScanner (60)
- Symbol (9)
モジュール
- Kernel (192)
-
MiniTest
:: Assertions (1)
キーワード
-
$ & (12) -
$ & # 39; (12) -
$ 1 (12) -
$ 10 (12) -
$ 11 (12) -
$ 2 (12) -
$ 3 (12) -
$ 4 (12) -
$ 5 (12) -
$ 6 (12) -
$ 7 (12) -
$ 8 (12) -
$ 9 (12) -
$ LAST _ PAREN _ MATCH (12) -
$ ` (12) -
$ ~ (12) -
1
. 6 . 8から1 . 8 . 0への変更点(まとめ) (12) - =~ (12)
- DateMatcher (12)
- DateTimeMatcher (12)
- MatchData (12)
-
NEWS for Ruby 2
. 4 . 0 (9) -
NEWS for Ruby 3
. 0 . 0 (5) - Regexp (12)
- accept (24)
-
assert
_ match (1) -
check
_ until (12) - compile (12)
-
last
_ match (24) - match? (39)
-
must
_ match (1) - names (12)
- new (12)
-
parse
_ files _ matching (12) -
ruby 1
. 6 feature (12) -
ruby 1
. 9 feature (12) -
scan
_ full (12) -
scan
_ until (12) -
skip
_ until (12) - ~ (12)
- 正規表現 (12)
検索結果
先頭5件
-
Regexp
. compile(string , option = nil , code = nil) -> Regexp (9228.0) -
文字列 string をコンパイルして正規表現オブジェクトを生成して返します。
...@param option Regexp::IGNORECASE, Regexp::MULTILINE,
Regexp::EXTENDED
の論理和を指定します。
Integer 以外であれば真偽値の指定として見なされ
、真(nil, false 以外)であれば
Regexp::IGNORECASE......を出力します。
@raise RegexpError 正規表現のコンパイルに失敗した場合発生します。
//emlist[例][ruby]{
str = "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_match # => "This is Regexp"
str = "ふるいけや\nかわずとびこむ\nみずのおと"
t2 = Regexp.compile("ふる.*?と", Regexp::MULTILINE)
p t2.match(str)[0] # => "... -
Regexp
. new(string , option = nil) -> Regexp (9228.0) -
文字列 string をコンパイルして正規表現オブジェクトを生成して返します。
...@param option Regexp::IGNORECASE, Regexp::MULTILINE,
Regexp::EXTENDED
の論理和を指定します。
Integer 以外であれば真偽値の指定として見なされ
、真(nil, false 以外)であれば
Regexp::IGNORECASE......じになります。
@raise RegexpError 正規表現のコンパイルに失敗した場合発生します。
//emlist[例][ruby]{
str = "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_match # => "This is Regexp"
str = "ふるいけや\nかわずとびこむ\nみずのおと"
t2 = Regexp.compile("ふる.*?と", Regexp::MULTILINE)
p t2.match(str)[0] # => "... -
Regexp
. new(string , option = nil , code = nil) -> Regexp (9228.0) -
文字列 string をコンパイルして正規表現オブジェクトを生成して返します。
...@param option Regexp::IGNORECASE, Regexp::MULTILINE,
Regexp::EXTENDED
の論理和を指定します。
Integer 以外であれば真偽値の指定として見なされ
、真(nil, false 以外)であれば
Regexp::IGNORECASE......を出力します。
@raise RegexpError 正規表現のコンパイルに失敗した場合発生します。
//emlist[例][ruby]{
str = "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_match # => "This is Regexp"
str = "ふるいけや\nかわずとびこむ\nみずのおと"
t2 = Regexp.compile("ふる.*?と", Regexp::MULTILINE)
p t2.match(str)[0] # => "... -
Regexp
# ~ -> Integer | nil (9060.0) -
変数 $_ の値との間でのマッチをとります。
...foo/
puts "match"
else
puts "no match"
end
# => no match
# ただし、警告がでる。warning: regex literal in condition
reg = Regexp.compile("foo")
if ~ reg
puts "match"
else
puts "no match"
end
# => no match
if reg
puts "match"
else
puts "no match"
end
# => match
# reg は ni... -
Regexp
# =~(string) -> Integer | nil (9036.0) -
文字列 string との正規表現マッチを行います。マッチした場合、 マッチした位置のインデックスを返します(先頭は0)。マッチしなかった 場合、あるいは string が nil の場合には nil を返 します。
...ruby]{
p /foo/ =~ "foo" # => 0
p /foo/ =~ "afoo" # => 1
p /foo/ =~ "bar" # => nil
//}
組み込み変数 $~ もしくは Regexp.last_match にマッチに関する情報 MatchData が設定されます。
文字列のかわりにSymbolをマッチさせることができます。
@param string......//emlist[例][ruby]{
p /foo/ =~ "foo" # => 0
p Regexp.last_match(0) # => "foo"
p /foo/ =~ "afoo" # => 1
p $~[0] # => "foo"
p /foo/ =~ "bar" # => nil
unless /foo/ === "bar"
puts "not match " # => not match
end
str = []
begin
/ugo/ =~ str
rescue TypeError... -
Symbol
# match?(regexp , pos = 0) -> bool (6330.0) -
regexp.match?(self, pos) と同じです。 regexp が文字列の場合は、正規表現にコンパイルします。 詳しくは Regexp#match? を参照してください。
...
regexp.match?(self, pos) と同じです。
regexp が文字列の場合は、正規表現にコンパイルします。
詳しくは Regexp#match? を参照してください。
例:
:Ruby.match?(/R.../) # => true
:Ruby.match?('Ruby') # => true
:Ruby.match?('Ruby',1) # => false
:R......uby.match?('uby',1) # => true
:Ruby.match?(/P.../) # => false
$& # => nil
@see Regexp#match?, String#match?... -
String
# match?(regexp , pos = 0) -> bool (6318.0) -
regexp.match?(self, pos) と同じです。 regexp が文字列の場合は、正規表現にコンパイルします。 詳しくは Regexp#match? を参照してください。
...
regexp.match?(self, pos) と同じです。
regexp が文字列の場合は、正規表現にコンパイルします。
詳しくは Regexp#match? を参照してください。
//emlist[例][ruby]{
"Ruby".match?(/R.../) #=> true
"Ruby".match?(/R.../, 1) #=> false
"Ruby".match?(/P.../) #=>......false
$& #=> nil
//}
@see Regexp#match?, Symbol#match?... -
StringScanner
# match?(regexp) -> Integer | nil (6248.0) -
スキャンポインタの地点だけで regexp と文字列のマッチを試します。 マッチしたら、スキャンポインタは進めずにマッチした 部分文字列の長さを返します。マッチしなかったら nil を 返します。
...スキャンポインタの地点だけで regexp と文字列のマッチを試します。
マッチしたら、スキャンポインタは進めずにマッチした
部分文字列の長さを返します。マッチしなかったら nil を
返します。
マッチしたサイズは文字単......e))
s.match?(/#{"\u{308B}".encode(encode)}/)
end
p case1("EUC-JP") #=> 2
//}
@param regexp マッチに用いる正規表現を指定します。
//emlist[例][ruby]{
require 'strscan'
s = StringScanner.new('test string')
p s.match?(/\w+/) #=> 4
p s.match?(/\w+/) #=> 4
p s.match?(/\s+/... -
RDoc
:: Parser # parse _ files _ matching(regexp) -> () (6223.0) -
regexp で指定した正規表現にマッチするファイルを解析できるパーサとして、 自身を登録します。
...
regexp で指定した正規表現にマッチするファイルを解析できるパーサとして、
自身を登録します。
@param regexp 正規表現を指定します。
新しいパーサを作成する時に使用します。
例:
class RDoc::Parser::Xyz < RDoc::Parser
parse_f......iles_matching /\.xyz$/
...
end... -
Object
# must _ match(regexp) -> true (6214.0) -
自身が与えられた正規表現にマッチした場合、検査にパスしたことになります。
...自身が与えられた正規表現にマッチした場合、検査にパスしたことになります。
@param regexp 正規表現か文字列を指定します。文字列を指定した場合は文字列そのものにマッチする
正規表現に変換してから使用し......ます。
@raise MiniTest::Assertion 自身が与えられた正規表現にマッチしなかった場合に発生します。
@see MiniTest::Assertions#assert_match... -
MiniTest
:: Assertions # assert _ match(regexp , str , message = nil) -> true (6208.0) -
与えられた文字列が与えられた正規表現にマッチした場合、検査にパスしたことになります。
...与えられた文字列が与えられた正規表現にマッチした場合、検査にパスしたことになります。
@param regexp 正規表現か文字列を指定します。文字列を指定した場合は文字列そのものにマッチする
正規表現に変換し... -
CSV
:: DateMatcher -> Regexp (6201.0) -
日付 (Date) 形式のデータを発見したり変換したりするための正規表現です。
日付 (Date) 形式のデータを発見したり変換したりするための正規表現です。 -
CSV
:: DateTimeMatcher -> Regexp (6201.0) -
日時 (DateTime) 形式のデータを発見したり変換したりするための正規表現です。
日時 (DateTime) 形式のデータを発見したり変換したりするための正規表現です。