ライブラリ
- ビルトイン (290)
-
irb
/ cmd / help (12) -
minitest
/ unit (1) -
net
/ telnet (8) - optparse (12)
- pathname (24)
- rake (12)
-
rdoc
/ context (24) -
rdoc
/ parser (12) -
rexml
/ document (12) -
rubygems
/ gem _ path _ searcher (24) -
rubygems
/ spec _ fetcher (24) - scanf (6)
- strscan (144)
クラス
-
Gem
:: GemPathSearcher (24) -
Gem
:: SpecFetcher (24) -
IRB
:: ExtendCommand :: Help (12) - MatchData (155)
-
Net
:: Telnet (8) - OptionParser (12)
- Pathname (24)
-
RDoc
:: Context (24) -
RDoc
:: Parser (12) -
REXML
:: Elements (12) - Regexp (57)
-
Scanf
:: FormatString (6) - String (57)
- StringScanner (144)
- Symbol (21)
モジュール
-
MiniTest
:: Assertions (1) -
Rake
:: TaskManager (12)
キーワード
- == (12)
- =~ (12)
- [] (36)
- accept (12)
-
assert
_ match (1) - begin (12)
- bytebegin (2)
- byteend (2)
- byteoffset (6)
-
check
_ until (12) - cmd (4)
- end (12)
-
enhance
_ with _ matching _ rule (12) - eql? (12)
- execute (12)
- fetch (12)
-
find
_ matching (12) - fnmatch (12)
- fnmatch? (12)
- gsub! (12)
-
last
_ match _ tried (6) - length (12)
- match? (39)
- matched (12)
- matched? (12)
-
matched
_ size (12) - matchedsize (12)
-
matching
_ file? (12) -
matching
_ files (12) -
named
_ captures (1) - offset (24)
-
parse
_ files _ matching (12) -
post
_ match (12) -
pre
_ match (12) -
scan
_ full (12) -
scan
_ until (12) - size (12)
-
skip
_ until (12) - sub! (12)
-
to
_ a (12) -
unmatched
_ alias _ lists (12) -
unmatched
_ alias _ lists= (12) - unscan (12)
-
values
_ at (12) - waitfor (4)
- ~ (12)
検索結果
先頭5件
-
StringScanner
# post _ match -> String | nil (6238.0) -
前回マッチを行った文字列のうち、マッチしたところよりも後ろの 部分文字列を返します。前回のマッチが失敗していると常に nil を 返します。
...ていると常に nil を
返します。
//emlist[例][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.sc......an(/\w+/) # => "string"
s.post_match # => ""
s.scan(/\w+/) # => nil
s.post_match # => nil
//}... -
StringScanner
# pre _ match -> String | nil (6238.0) -
前回マッチを行った文字列のうち、マッチしたところよりも前の 部分文字列を返します。前回のマッチが失敗していると常に nil を 返します。
...していると常に 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.scan(/\w+/) # => nil
s.pre_match # => nil
//}... -
Regexp
# match?(str , pos = 0) -> bool (6226.0) -
指定された文字列 str に対して 位置 pos から自身が表す正規表現によるマッチングを行います。 マッチした場合 true を返し、マッチしない場合には false を返します。 また、$~ などパターンマッチに関する組み込み変数の値は変更されません。
...は false を返します。
また、$~ などパターンマッチに関する組み込み変数の値は変更されません。
//emlist[例][ruby]{
/R.../.match?("Ruby") # => true
/R.../.match?("Ruby", 1) # => false
/P.../.match?("Ruby") # => false
$& # => nil
//}......@see Regexp#match... -
StringScanner
# match?(regexp) -> Integer | nil (6226.0) -
スキャンポインタの地点だけで regexp と文字列のマッチを試します。 マッチしたら、スキャンポインタは進めずにマッチした 部分文字列の長さを返します。マッチしなかったら nil を 返します。
...ッチしなかったら nil を
返します。
マッチしたサイズは文字単位でなくバイト単位となります。
//emlist[][ruby]{
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 'strscan'
s = StringScanner.new('test string')
p s.match?(/\w+/) #=> 4
p s.match?(/\w+/) #=> 4
p s.match?(/\s+/) #=> nil
//}... -
MiniTest
:: Assertions # assert _ match(regexp , str , message = nil) -> true (6202.0) -
与えられた文字列が与えられた正規表現にマッチした場合、検査にパスしたことになります。
...した場合に表示するメッセージを指定します。
文字列か Proc を指定します。Proc である場合は Proc#call した
結果を使用します。
@raise MiniTest::Assertion 与えられた文字列が与えられた正規表現にマッチし... -
Pathname
# fnmatch(pattern , *args) -> bool (6201.0) -
File.fnmatch(pattern, self.to_s, *args) と同じです。
...File.fnmatch(pattern, self.to_s, *args) と同じです。
@param pattern パターンを文字列で指定します。ワイルドカードとして `*', `?', `[]' が使用できま
す。Dir.glob とは違って `{}' や `**/' は使用できません。
@param args File.fnmatch......を参照してください。
//emlist[例][ruby]{
require "pathname"
path = Pathname("testfile")
path.fnmatch("test*") # => true
path.fnmatch("TEST*") # => false
path.fnmatch("TEST*", File::FNM_CASEFOLD) # => true
//}
@see File.fnmatch... -
Pathname
# fnmatch?(pattern , *args) -> bool (6201.0) -
File.fnmatch?(pattern, self.to_s, *args) と同じです。
...ile.fnmatch?(pattern, self.to_s, *args) と同じです。
@param pattern パターンを文字列で指定します。ワイルドカードとして `*', `?', `[]' が使用できま
す。Dir.glob とは違って `{}' や `**/' は使用できません。
@param args File.fnmatch......を参照してください。
@see File.fnmatch?... -
StringScanner
# matched -> String | nil (6201.0) -
前回マッチした部分文字列を返します。 前回のマッチに失敗していると nil を返します。
...に失敗していると nil を返します。
//emlist[例][ruby]{
require 'strscan'
s = StringScanner.new('test string')
s.matched # => nil
s.scan(/\w+/) # => "test"
s.matched # => "test"
s.scan(/\w+/) # => nil
s.matched # => nil
s.scan(/\s+/) # => " "
s.matched # => " "
//}... -
StringScanner
# matched? -> bool (6201.0) -
前回のマッチが成功していたら true を、 失敗していたら false を返します。
...失敗していたら false を返します。
//emlist[例][ruby]{
require 'strscan'
s = StringScanner.new('test string')
s.matched? # => false
s.scan(/\w+/) # => "test"
s.matched? # => true
s.scan(/\w+/) # => nil
s.matched? # => false
s.scan(/\s+/) # => " "
s.matched? # => true
//}... -
StringScanner
# matched _ size -> Integer | nil (6201.0) -
前回マッチした部分文字列の長さを返します。 前回マッチに失敗していたら nil を返します。
...nil を返します。
マッチしたサイズは文字単位でなくバイト単位となります。
//emlist[][ruby]{
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
//}... -
StringScanner
# matchedsize -> Integer | nil (6201.0) -
StringScanner#matched_size と同じです。
...StringScanner#matched_size と同じです。
このメソッドは は将来のバージョンで削除される予定です。
代わりに StringScanner#matched_size を使ってください。
@see StringScanner#matched_size...