るりまサーチ

最速Rubyリファレンスマニュアル検索!
11件ヒット [1-11件を表示] (0.073秒)
トップページ > クエリ:IO[x] > クエリ:p[x] > クエリ:egrep[x]

別のキーワード

  1. io popen
  2. io pipe
  3. io each
  4. io readlines
  5. io each_line

ライブラリ

クラス

検索結果

Rake::FileList#egrep(pattern) {|filename, count, line| ... } (24225.0)

与えられたパターンをファイルリストから grep のように検索します。

...与えられたパターンをファイルリストから grep のように検索します。

ブロックが与えられた場合は、マッチした行の情報 (ファイル名、行番号、マッチした行) が
ブロックに渡されてブロックが評価されます。ブロックが...
...

@param pattern 正規表現を指定します。

//emlist[][ruby]{
# Rakefile での記載例とする

IO
.write("sample1", "line1\nline2\nline3\n")
IO
.write("sample2", "line1\nline2\nline3\nline4\n")

task default: :test_rake_app
task :test_rake_app do

file_list = FileList.new('sample*')...
...file_list.egrep(/line/) # => 7

file_list.egrep(/.*/) do |filename, count, line|
"filename = #{filename}, count = #{count}, line = #{line}"
end
end

# => "filename = sample1, count = 1, line = line1\n"
# => "filename = sample1, count = 2, line = line2\n"
# => "filename = sample1, count = 3,...