別のキーワード
種類
- インスタンスメソッド (474)
- 特異メソッド (108)
- モジュール関数 (24)
ライブラリ
- ビルトイン (344)
-
irb
/ cmd / help (12) -
minitest
/ spec (1) -
minitest
/ unit (1) -
net
/ telnet (8) - optparse (24)
- pathname (36)
- rake (12)
-
rdoc
/ context (12) -
rdoc
/ parser (12) -
rexml
/ document (36) -
rubygems
/ gem _ path _ searcher (24) -
rubygems
/ spec _ fetcher (24) - strscan (60)
クラス
- File (24)
-
Gem
:: GemPathSearcher (24) -
Gem
:: SpecFetcher (24) -
IRB
:: ExtendCommand :: Help (12) - MatchData (152)
-
Net
:: Telnet (8) - Object (1)
- OptionParser (24)
- Pathname (36)
-
RDoc
:: Context (12) -
RDoc
:: Parser (12) -
REXML
:: Elements (12) -
REXML
:: Entity (12) -
REXML
:: XPath (12) - Regexp (84)
- String (48)
- StringScanner (60)
- Symbol (12)
モジュール
- Kernel (24)
-
MiniTest
:: Assertions (1) -
Rake
:: TaskManager (12)
キーワード
- == (12)
- =~ (12)
- [] (48)
- accept (24)
-
assert
_ match (1) - begin (12)
- byteoffset (6)
-
check
_ until (12) - cmd (4)
- compile (12)
-
deconstruct
_ keys (2) - end (12)
-
enhance
_ with _ matching _ rule (12) - eql? (12)
- execute (12)
- fetch (12)
-
find
_ matching (12) - fnmatch (24)
- fnmatch? (24)
- gsub (24)
- gsub! (12)
-
last
_ match (24) - match? (12)
- matches? (12)
-
matching
_ file? (12) -
matching
_ files (12) -
must
_ match (1) -
named
_ captures (12) - new (12)
- offset (24)
-
parse
_ files _ matching (12) -
scan
_ full (12) -
scan
_ until (12) -
skip
_ until (12) - sub (36)
- sub! (12)
-
to
_ a (12) -
unmatched
_ alias _ lists= (12) -
values
_ at (12) - waitfor (4)
検索結果
先頭5件
-
Regexp
# match(str , pos = 0) -> MatchData | nil (18316.0) -
指定された文字列 str に対して位置 pos から自身が表す正規表現によるマッ チングを行います。マッチした場合には結果を MatchData オブジェクトで返し ます。 マッチしなかった場合 nil を返します。
...字列 str に対して位置 pos から自身が表す正規表現によるマッ
チングを行います。マッチした場合には結果を MatchData オブジェクトで返し
ます。
マッチしなかった場合 nil を返します。
省略可能な第二引数 pos を指定すると......captures) # => ["b", "r"]
p(/(.).(.)/.match("foobar", -3).captures) # => ["b", "r"]
//}
pos を指定しても MatchData#offset 等の結果
には影響しません。つまり、
//emlist[][ruby]{
re.match(str[pos..-1])
//}
と
//emlist[][ruby]{
re.match(str, pos)
//}
は異なります。......t[例][ruby]{
results = []
/((.)\2)/.match("foo") {|m| results << m[0] } # => ["oo"]
/((.)\2)/.match("bar") {|m| results << m[0] } # => nil
results # => ["oo"]
//}
@param str 文字列を指定します。str との正規表現マッチを行います。
@param pos 整数を指定します。マ... -
Symbol
# match(other) -> MatchData | nil (18243.0) -
正規表現 other とのマッチを行います。
....match(other) と同じです。)
@param other 比較対象のシンボルを指定します。
@return マッチが成功すれば MatchData オブジェクトを、そうでなければ nil を返します。
p :foo.match(/foo/) # => #<MatchData "foo">
p :foobar.match(/bar/) # => #<Match......Data "bar">
p :foo.match(/bar/) # => nil
@see String#match
@see Symbol#match?... -
Regexp
# match(str , pos = 0) {|m| . . . } -> object | nil (18216.0) -
指定された文字列 str に対して位置 pos から自身が表す正規表現によるマッ チングを行います。マッチした場合には結果を MatchData オブジェクトで返し ます。 マッチしなかった場合 nil を返します。
...字列 str に対して位置 pos から自身が表す正規表現によるマッ
チングを行います。マッチした場合には結果を MatchData オブジェクトで返し
ます。
マッチしなかった場合 nil を返します。
省略可能な第二引数 pos を指定すると......captures) # => ["b", "r"]
p(/(.).(.)/.match("foobar", -3).captures) # => ["b", "r"]
//}
pos を指定しても MatchData#offset 等の結果
には影響しません。つまり、
//emlist[][ruby]{
re.match(str[pos..-1])
//}
と
//emlist[][ruby]{
re.match(str, pos)
//}
は異なります。......t[例][ruby]{
results = []
/((.)\2)/.match("foo") {|m| results << m[0] } # => ["oo"]
/((.)\2)/.match("bar") {|m| results << m[0] } # => nil
results # => ["oo"]
//}
@param str 文字列を指定します。str との正規表現マッチを行います。
@param pos 整数を指定します。マ... -
Symbol
# match(other) -> Integer | nil (18137.0) -
正規表現 other とのマッチを行います。
...elf.to_s.match(other) と同じです。)
@param other 比較対象のシンボルを指定します。
@return マッチが成功すればマッチした位置を、そうでなければ nil を返します。
p :foo.match(/foo/) # => 0
p :foobar.match(/bar/) # => 3
p :foo.match(/bar/)......# => nil
@see String#match... -
REXML
:: XPath . match(element , path = nil , namespaces = {} , variables = {}) -> [Node] (18131.0) -
element の path で指定した XPath 文字列にマッチするノードの配列を 返します。
...避けるため、適切な
エスケープを付加するため、に用います。
@param element 要素(REXML::Element)
@param path XPath文字列
@param namespace 名前空間とURLの対応付け
@param variables 変数名とその値の対応付け
//emlist[][ruby]{
require 'rexml/document'......doc = REXML::Document.new(<<EOS)
<root xmlns:x='1'>
<a>
<b>b1</b>
<x:c />
<b>b2</b>
<d />
</a>
<b> b3 </b>
</root>
EOS
REXML::XPath.match(doc, "/root/a/b") # => [<b> ... </>, <b> ... </>]
//}... -
Regexp
. last _ match -> MatchData (6244.0) -
カレントスコープで最後に行った正規表現マッチの MatchData オ ブジェクトを返します。このメソッドの呼び出しは $~ の参照と同じです。
... MatchData オ
ブジェクトを返します。このメソッドの呼び出しは $~
の参照と同じです。
//emlist[例][ruby]{
/(.)(.)/ =~ "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
//}... -
Gem
:: SpecFetcher # find _ matching(dependency , all = false , matching _ platform = true) -> Array (6218.0) -
依存関係を満たす gemspec の名前の配列を返します。
...存関係を満たす gemspec の名前の配列を返します。
@param dependency 依存関係を指定します。
@param all 真を指定するとマッチする全てのバージョンの情報を返します。
@param matching_platform 偽を指定すると全てのプラットフォーム... -
Regexp
. last _ match(nth) -> String | nil (6179.0) -
整数 nth が 0 の場合、マッチした文字列を返します ($&)。それ以外では、nth 番目の括弧にマッチ した部分文字列を返します($1,$2,...)。 対応する括弧がない場合やマッチしなかった場合には nil を返し ます。
..."
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 はnil を返......すため、
last_match[1] の形式では例外 NoMethodError が発生します。
対して、last_match(1) は nil を返します。
//emlist[例][ruby]{
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 整数を指定します。
整数 nth が 0 の場合、マッチした文字列を返します。それ以外では、nth 番目の括弧にマッチした部分文字列を返します。... -
StringScanner
# match?(regexp) -> Integer | nil (6131.0) -
スキャンポインタの地点だけで 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+/... -
MiniTest
:: Assertions # assert _ match(regexp , str , message = nil) -> true (6119.0) -
与えられた文字列が与えられた正規表現にマッチした場合、検査にパスしたことになります。
...なります。
@param regexp 正規表現か文字列を指定します。文字列を指定した場合は文字列そのものにマッチする
正規表現に変換してから使用します。
@param str 検査対象の文字列を指定します。
@param message 検査に... -
File
. fnmatch(pattern , path , flags = 0) -> bool (6118.0) -
ファイル名のパターンマッチ fnmatch(3) を行います。 path が pattern にマッチすれば真を返します。そうでない場合には false を返します。
...ファイル名のパターンマッチ fnmatch(3) を行います。
path が pattern にマッチすれば真を返します。そうでない場合には false を返します。
@param pattern パターンを文字列で指定します。ワイルドカードとして `*',
`**`,......{}' が使用できます。
//emlist[例][ruby]{
%w(foo foobar bar).each {|f|
p File.fnmatch("foo*", f)
}
# => true
# true
# false
//}
@param path パスを表す文字列を指定します。
@param flags パターンマッチの動作を以下で述べる定数の論理和で指定し......//emlist[][ruby]{
p File.fnmatch('\a', 'a') # => true
p File.fnmatch('\a', '\a', File::FNM_NOESCAPE) # => true
//}
前者で * は、エスケープされているので "*" そのものにマッチ
します。
//emlist[][ruby]{
p File.fnmatch('\*', 'a')...