るりまサーチ

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

別のキーワード

  1. _builtin to_i
  2. fiddle to_i
  3. matrix elements_to_i
  4. csv to_i
  5. matrix i

ライブラリ

クラス

モジュール

キーワード

検索結果

<< 1 2 3 ... > >>

Enumerator::Lazy#grep(pattern) {|item| ... } -> Enumerator::Lazy (18253.0)

Enumerable#grep と同じですが、配列ではなくEnumerator::Lazy を返します。

...erable#grep と同じですが、配列ではなくEnumerator::Lazy を返します。

//emlist[例][ruby]{
(100..Float::INFINITY).lazy.map(&:to_s).grep(/\A(\d)\1+\z/)
# => #<Enumerator::Lazy: #<Enumerator::Lazy: #<Enumerator::Lazy: 100..Infinity>:map>:grep(/\A(\d)\1+\z/)>
(100..Float::INFINITY).la...
...zy.map(&:to_s).grep(/\A(\d)\1+\z/).take(10).force
# => ["111", "222", "333", "444", "555", "666", "777", "888", "999", "1111"]
//}

@see Enumerable#grep...
...zy.map(&:to_s).grep(/\A(\d)\1+\z/).take(10).force
# => ["111", "222", "333", "444", "555", "666", "777", "888", "999", "1111"]
//}

@see Enumerable#grep, Enumerable#grep_v, Enumerator::Lazy#grep_v...

Enumerable#grep(pattern) {|item| ... } -> [object] (18226.0)

pattern === item が成立する要素を全て含んだ配列を返します。

...pattern === item が成立する要素を全て含んだ配列を返します。

ブロックとともに呼び出された時には条件の成立した要素に対して
それぞれブロックを評価し、その結果の配列を返します。
マッチする要素がひとつもなかっ...
...返します。

@param pattern 「===」メソッドを持つオブジェクトを指定します。

//emlist[例][ruby]{
['aa', 'bb', 'cc', 'dd', 'ee'].grep(/[bc]/) # => ["bb", "cc"]

Array.instance_methods.grep(/gr/) # => [:grep, :group_by]
//}

@see Enumerable#select
@see Enumerable#grep_v...

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

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

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

ブロックが与えられた場合は、マッチした行の情報 (ファイル名、行番号、マッチした行) が
ブロックに渡されてブロックが評価されます。ブロックが...
...//emlist[][ruby]{
# Rakefile での記載例とする

I
O.write("sample1", "line1\nline2\nline3\n")
I
O.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(/.*/...
...|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, line = line3\n"
# => "filename = sample2, count = 1, line...

Enumerator::Lazy#grep_v(pattern) {|item| ... } -> Enumerator::Lazy (6253.0)

Enumerable#grep_v と同じですが、配列ではなくEnumerator::Lazy を返します。

...erable#grep_v と同じですが、配列ではなくEnumerator::Lazy を返します。

//emlist[例][ruby]{
(100..Float::INFINITY).lazy.map(&:to_s).grep_v(/(\d).*\1/)
# => #<Enumerator::Lazy: #<Enumerator::Lazy: #<Enumerator::Lazy: 100..Infinity>:map>:grep_v(/(\d).*\1/)>
(100..Float::INFINITY).la...
...zy.map(&:to_s).grep_v(/(\d).*\1/).take(15).force
# => ["102", "103", "104", "105", "106", "107", "108", "109", "120", "123", "124", "125", "126", "127", "128"]
//}

@see Enumerable#grep_v, Enumerable#grep, Enumerator::Lazy#grep...

Enumerable#grep_v(pattern) { |item| ... } -> [object] (6236.0)

Enumerable#grep のマッチの条件を逆にして、pattern === item が成立 しない要素を全て含んだ配列を返します。

...Enumerable#grep のマッチの条件を逆にして、pattern === item が成立
しない要素を全て含んだ配列を返します。

@param pattern 「===」メソッドを持つオブジェクトを指定します。

//emlist[例][ruby]{
(1..10).grep_v 2..5 # => [1, 6, 7, 8, 9, 10]
res...
...=(1..10).grep_v(2..5) { |v| v * 2 }
res # => [2, 12, 14, 16, 18, 20]
//}

@see Enumerable#grep
@see Enumerable#reject...

絞り込み条件を変える

Shellwords.#shelljoin(array) -> String (6212.0)

配列の各要素である文字列に対して、Bourne シェルのコマンドライン中で安全に 使えるためのエスケープを適用し、空白文字を介してそれらを連結したコマンド ライン文字列を生成します。

...る配列を指定します。
@return エスケープ結果を連結した文字列を返します。

例:
require 'shellwords'

pattern = 'Jan 15'
file = 'file name with spaces'
puts Shellwords.shelljoin(['grep', pattern, file])
# => grep Jan\ 15 file\ name\ with\ spaces...

Enumerable#filter -> Enumerator (6118.0)

各要素に対してブロックを評価した値が真であった要素を全て含む配列を 返します。真になる要素がひとつもなかった場合は空の配列を返します。

...を返します。

ブロックを省略した場合は Enumerator を返します。

//emlist[例][ruby]{
(1..10).find_all # => #<Enumerator: 1..10:find_all>
(1..10).find_all { |i| i % 3 == 0 } # => [3, 6, 9]

[1,2,3,4,5].select # => #<Enumerator: [...
...1, 2, 3, 4, 5]:select>
[1,2,3,4,5].select { |num| num.even? } # => [2, 4]
//}

@see Enumerable#reject
@see Enumerable#grep...

Enumerable#filter {|item| ... } -> [object] (6118.0)

各要素に対してブロックを評価した値が真であった要素を全て含む配列を 返します。真になる要素がひとつもなかった場合は空の配列を返します。

...を返します。

ブロックを省略した場合は Enumerator を返します。

//emlist[例][ruby]{
(1..10).find_all # => #<Enumerator: 1..10:find_all>
(1..10).find_all { |i| i % 3 == 0 } # => [3, 6, 9]

[1,2,3,4,5].select # => #<Enumerator: [...
...1, 2, 3, 4, 5]:select>
[1,2,3,4,5].select { |num| num.even? } # => [2, 4]
//}

@see Enumerable#reject
@see Enumerable#grep...

Enumerable#find_all -> Enumerator (6118.0)

各要素に対してブロックを評価した値が真であった要素を全て含む配列を 返します。真になる要素がひとつもなかった場合は空の配列を返します。

...を返します。

ブロックを省略した場合は Enumerator を返します。

//emlist[例][ruby]{
(1..10).find_all # => #<Enumerator: 1..10:find_all>
(1..10).find_all { |i| i % 3 == 0 } # => [3, 6, 9]

[1,2,3,4,5].select # => #<Enumerator: [...
...1, 2, 3, 4, 5]:select>
[1,2,3,4,5].select { |num| num.even? } # => [2, 4]
//}

@see Enumerable#reject
@see Enumerable#grep...

Enumerable#find_all {|item| ... } -> [object] (6118.0)

各要素に対してブロックを評価した値が真であった要素を全て含む配列を 返します。真になる要素がひとつもなかった場合は空の配列を返します。

...を返します。

ブロックを省略した場合は Enumerator を返します。

//emlist[例][ruby]{
(1..10).find_all # => #<Enumerator: 1..10:find_all>
(1..10).find_all { |i| i % 3 == 0 } # => [3, 6, 9]

[1,2,3,4,5].select # => #<Enumerator: [...
...1, 2, 3, 4, 5]:select>
[1,2,3,4,5].select { |num| num.even? } # => [2, 4]
//}

@see Enumerable#reject
@see Enumerable#grep...

絞り込み条件を変える

Kernel.#require(feature) -> bool (6112.0)

Ruby ライブラリ feature をロードします。拡張子補完を行い、 同じファイルの複数回ロードはしません。

...字列です。
@raise LoadError ロードに失敗した場合に発生します。

//emlist[例][ruby]{
$LOADED_FEATURES.grep(/prime/).size # => 0
require "prime" # => true
$LOADED_FEATURES.grep(/prime/).size # => 1
require "prime" # => false
begin
require "invalid"
rescue LoadError...
...=> e
e.message # => "cannot load such file -- invalid"
end
//}

@see Kernel.#load,Kernel.#autoload,Kernel.#require_relative...
<< 1 2 3 ... > >>