るりまサーチ

最速Rubyリファレンスマニュアル検索!
374件ヒット [1-100件を表示] (0.102秒)

別のキーワード

  1. kernel require
  2. getoptlong require_order
  3. rubygems/custom_require require
  4. irb/ext/use-loader irb_require
  5. require execute

ライブラリ

クラス

モジュール

キーワード

検索結果

<< 1 2 3 ... > >>

REXML::XPath.match(element, path = nil, namespaces = {}, variables = {}) -> [Node] (18113.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> ... </>]
//}...

Kernel$$LAST_MATCH_INFO -> MatchData | nil (6225.0)

$~ の別名

...$~ の別名

require
"English"

str = "<a href=https://www.ruby-lang.org/en/about/license.txt>license</a>"

if /<a href=(.+?)>/ =~ str
p $LAST_MATCH_INFO[0] #=> "<a href=https://www.ruby-lang.org/en/about/license.txt>"
p $LAST_MATCH_INFO[1] #=> "https://www.ruby-lang.org/en/about/lic...
...ense.txt"
p $LAST_MATCH_INFO[2] #=> nil
end...

StringScanner#post_match -> String | nil (6143.0)

前回マッチを行った文字列のうち、マッチしたところよりも後ろの 部分文字列を返します。前回のマッチが失敗していると常に nil を 返します。

...st[例][ruby]{
require
'strscan'

s = StringScanner.new('test string')
s.post_match # => nil
s.scan(/\w+/) # => "test"
s.post_match # => " string"
s.scan(/\w+/) # => nil
s.post_match # => nil
s.scan(/\s+/) # => " "
s.post_match # => "string"
s.scan(/\w+/) # => "string"
s.post_match # => ""
s.sc...
...an(/\w+/) # => nil
s.post_match # => nil
//}...

StringScanner#pre_match -> String | nil (6143.0)

前回マッチを行った文字列のうち、マッチしたところよりも前の 部分文字列を返します。前回のマッチが失敗していると常に nil を 返します。

.../emlist[例][ruby]{
require
'strscan'

s = StringScanner.new('test string')
s.pre_match # => nil
s.scan(/\w+/) # => "test"
s.pre_match # => ""
s.scan(/\w+/) # => nil
s.pre_match # => nil
s.scan(/\s+/) # => " "
s.pre_match # => "test"
s.scan(/\w+/) # => "string"
s.pre_match # => "test "
s.s...
...can(/\w+/) # => nil
s.pre_match # => nil
//}...

StringScanner#match?(regexp) -> Integer | nil (6137.0)

スキャンポインタの地点だけで regexp と文字列のマッチを試します。 マッチしたら、スキャンポインタは進めずにマッチした 部分文字列の長さを返します。マッチしなかったら nil を 返します。

...uby]{
require
'strscan'
def case1(encode)
utf8 = "\u{308B 3073 3044}"
s = StringScanner.new(utf8.encode(encode))
s.match?(/#{"\u{308B}".encode(encode)}/)
end

p case1("EUC-JP") #=> 2
//}

@param regexp マッチに用いる正規表現を指定します。

//emlist[例][ruby]{
require
'st...
...rscan'

s = StringScanner.new('test string')
p s.match?(/\w+/) #=> 4
p s.match?(/\w+/) #=> 4
p s.match?(/\s+/) #=> nil
//}...

絞り込み条件を変える

Kernel$$MATCH -> String | nil (6113.0)

$& の別名

...$& の別名

require
"English"

str = 'hoge,foo,bar,hee,hoo'

/(foo|bar)/ =~ str
p $MATCH #=> "foo"...

StringScanner#matched_size -> Integer | nil (6112.0)

前回マッチした部分文字列の長さを返します。 前回マッチに失敗していたら nil を返します。

...y]{
require
'strscan'

def run(encode)
utf8 = "\u{308B 3073 3044}" # るびい
s = StringScanner.new(utf8.encode(encode))
s.scan(/#{"\u{308B}".encode(encode)}/)
s.matched_size
end

p run("UTF-8") #=> 3
p run("EUC-JP") #=> 2
p run("Shift_Jis") #=> 2

//}

//emlist[例][ruby]{
require
'...
...strscan'

s = StringScanner.new('test string')
s.matched_size # => nil
s.scan(/\w+/) # => "test"
s.matched_size # => 4
s.scan(/\w+/) # => nil
s.matched_size # => nil
//}...

Kernel$$LAST_PAREN_MATCH -> String | nil (6107.0)

$+ の別名

...$+ の別名

require
"English"

r1 = Regexp.compile("<img src=(http:.+?)>")
r2 = Regexp.compile("<a href=(http|ftp).+?>(.+?)</a>")

while line = DATA.gets
[ r1, r2 ].each {|rep|
rep =~ line
p $+
}
end
__END__
<tr> <td><img src=http://localhost/a.jpg></td> <td>ikko...

Kernel$$POSTMATCH -> String | nil (6106.0)

$' の別名

...$' の別名

require
"English"

str = 'hoge,foo,bar,hee,hoo'

/foo/ =~ str
p $POSTMATCH #=> ",bar,hee,hoo"...
<< 1 2 3 ... > >>