ライブラリ
- ビルトイン (66)
- optparse (11)
-
rexml
/ document (22) -
rinda
/ rinda (11) -
ripper
/ lexer (11) -
rubygems
/ platform (11)
クラス
- File (22)
-
Gem
:: Platform (11) - OptionParser (11)
-
REXML
:: Entity (11) -
REXML
:: XPath (11) - Regexp (44)
-
Rinda
:: DRbObjectTemplate (11) - Ripper (11)
キーワード
- accept (11)
- compile (11)
- fnmatch (11)
- fnmatch? (11)
-
last
_ match (22) - matches? (11)
- new (22)
-
token
_ match (11)
検索結果
先頭5件
-
REXML
:: XPath . match(element , path = nil , namespaces = {} , variables = {}) -> [Node] (18108.0) -
element の path で指定した XPath 文字列にマッチするノードの配列を 返します。
...s 変数名とその値の対応付け
//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> ... </>]
//}... -
Gem
:: Platform . match(platform) -> bool (18102.0) -
@todo ???
@todo ??? -
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
//}... -
Ripper
. token _ match(src , pattern) -> Ripper :: TokenPattern :: MatchData | nil (6202.0) -
Ruby プログラム src に対してパターン pattern をマッチし、 マッチデータを返します。
Ruby プログラム src に対してパターン pattern をマッチし、
マッチデータを返します。
ライブラリ内部で使用します。 -
Regexp
. last _ match(nth) -> String | nil (6174.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 番目の括弧にマッチした部分文字列を返します。... -
File
. fnmatch(pattern , path , flags = 0) -> bool (6101.0) -
ファイル名のパターンマッチ fnmatch(3) を行います。 path が pattern にマッチすれば真を返します。そうでない場合には false を返します。
...ファイル名のパターンマッチ fnmatch(3) を行います。
path が pattern にマッチすれば真を返します。そうでない場合には false を返します。
@param pattern パターンを文字列で指定します。ワイルドカードとして `*',
`?',......きます。
Dir.glob とは違って `**/' は使用できません。
//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')... -
File
. fnmatch?(pattern , path , flags = 0) -> bool (6101.0) -
ファイル名のパターンマッチ fnmatch(3) を行います。 path が pattern にマッチすれば真を返します。そうでない場合には false を返します。
...ファイル名のパターンマッチ fnmatch(3) を行います。
path が pattern にマッチすれば真を返します。そうでない場合には false を返します。
@param pattern パターンを文字列で指定します。ワイルドカードとして `*',
`?',......きます。
Dir.glob とは違って `**/' は使用できません。
//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')... -
REXML
:: Entity . matches?(string) -> bool (6101.0) -
string が実体宣言の文法に従う文字列であれば真を返します。
...あれば真を返します。
@param string 判定対象の文字列
//emlist[][ruby]{
require 'rexml/document'
p REXML::Entity.matches?('<!ENTITY s "seal">') # => true
p REXML::Entity.matches?('<!ENTITY % s "seal">') # => true
p REXML::Entity.matches?('<!ELEMENT br EMPTY >') # => false
//}... -
Regexp
. compile(string , option = nil , code = nil) -> Regexp (25.0) -
文字列 string をコンパイルして正規表現オブジェクトを生成して返します。
...s 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] # => "ふるいけや\nかわずと"
//}... -
Regexp
. new(string , option = nil , code = nil) -> Regexp (25.0) -
文字列 string をコンパイルして正規表現オブジェクトを生成して返します。
...s 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] # => "ふるいけや\nかわずと"
//}...