374件ヒット
[1-100件を表示]
(0.102秒)
別のキーワード
ライブラリ
- English (60)
- ビルトイン (12)
- csv (12)
-
net
/ telnet (2) - optparse (24)
- pathname (24)
-
rexml
/ document (36) -
rinda
/ rinda (12) - strscan (132)
クラス
- Object (12)
- OptionParser (24)
- Pathname (24)
-
REXML
:: Elements (12) -
REXML
:: Entity (12) -
REXML
:: XPath (12) - StringScanner (132)
モジュール
- Kernel (60)
キーワード
-
$ LAST _ MATCH _ INFO (12) -
$ LAST _ PAREN _ MATCH (12) -
$ MATCH (12) -
$ POSTMATCH (12) -
$ PREMATCH (12) - CSV (12)
-
SCRIPT
_ LINES _ _ (12) - Telnet (2)
- Template (12)
- accept (24)
-
check
_ until (12) - fnmatch (12)
- irb (12)
- match? (12)
- matched (12)
- matched? (12)
-
matched
_ size (12) - matches? (12)
-
post
_ match (12) -
pre
_ match (12) -
rexml
/ document (12) -
ruby 1
. 6 feature (12) -
ruby 1
. 8 . 4 feature (12) -
ruby 1
. 9 feature (12) -
scan
_ full (12) -
scan
_ until (12) -
skip
_ until (12) - sub (12)
-
to
_ a (12) - unscan (12)
検索結果
先頭5件
-
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"...