るりまサーチ

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

別のキーワード

  1. openssl p
  2. openssl p=
  3. fileutils mkdir_p
  4. kernel p
  5. dh p

モジュール

キーワード

検索結果

<< < 1 2 3 4 5 ... > >>

パターンマッチ (6208.0)

パターンマッチ * patterns * variable_binding * variable_pinning * matching_non_primitive_objects * guard_clauses * current_feature_status * pattern_syntax * some_undefined_behavior_examples

...パターンマッチ
* patterns
* variable_binding
* variable_pinning
* matching_non_primitive_objects
* guard_clauses
* current_feature_status
* pattern_syntax
* some_undefined_behavior_examples

パターンマッチは、構造化された値に対して、構造をチェック...
...チは in 演算子を用いて実装されており、単体の式や

<expression> in <pattern>

case 文の中で利用できます。

case <expression>
in <pattern1>
...
in <pattern2>
...
in <pattern3>
...
else
...
end

in 節と when 節は1つの case 式の中...
...ッチせず else 節がない場合、例外 NoMatchingPatternError が発生します。

そのため、条件付きのマッチや展開に case 式が使われることがあります。

//emlist[][ruby]{
config = {db: {user: 'admin', password: 'abc123'}}

case config
in db: {user:} # ネス...

Rake::FileList#egrep(pattern) {|filename, count, line| ... } (6207.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,...

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

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

...rep と同じですが、配列ではなく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).lazy.map(&...
...:to_s).grep(/\A(\d)\1+\z/).take(10).force
# => ["111", "222", "333", "444", "555", "666", "777", "888", "999", "1111"]
//}

@see Enumerable#grep...
...: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...

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

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

...rep_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).lazy.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...

MatchData#captures -> [String] (6118.0)

$1, $2, ... を格納した配列を返します。

...応する要素は nil になります。

//emlist[例][ruby]{
/(foo)(bar)(BAZ)?/ =~ "foobarbaz"
p
$~.to_a # => ["foobar", "foo", "bar", nil]
p
$~.captures # => ["foo", "bar", nil]
//}

@see MatchData#to_a, MatchData#named_captures, d:spec/pattern_matching#matching_non_primitive_objects...

絞り込み条件を変える

Rake::Application#options -> OpenStruct (6112.0)

コマンドラインで与えられたアプリケーションのオプションを返します。

...ake_app
task :test_rake_app do
Rake.application.options # => #<OpenStruct always_multitask=false, backtrace=false, build_all=false, dryrun=false, ignore_deprecate=false, ignore_system=false, job_stats=false, load_system=false, nosearch=false, rakelib=["rakelib"], show_all_tasks=false, show_prereq...
...s=false, show_task_pattern=nil, show_tasks=nil, silent=false, suppress_backtrace_pattern=nil, thread_pool_size=8, trace=false, trace_output=#<IO:<STDERR>>, trace_rules=false>
end
//}...

Shellwords.#shellescape(str) -> String (6112.0)

文字列を Bourne シェルのコマンドライン中で安全に使えるようにエスケープします。

...ープします。

@param str エスケープの対象となる文字列を指定します。
@return エスケープされた文字列を返します。

例:
require 'shellwords'

pattern
= 'Jan 15'
p
uts "grep #{Shellwords.shellescape(pattern)} file"
# => grep Jan\ 15 file...

Ripper.token_match(src, pattern) -> Ripper::TokenPattern::MatchData | nil (3417.0)

Ruby プログラム src に対してパターン pattern をマッチし、 マッチデータを返します。

...Ruby プログラム src に対してパターン pattern をマッチし、
マッチデータを返します。

ライブラリ内部で使用します。...

Regexp.union(*pattern) -> Regexp (3329.0)

引数として与えた pattern を選択 | で連結し、Regexp として返します。 結果の Regexp は与えた pattern のどれかにマッチする場合にマッチするものになります。

...引数として与えた pattern を選択 | で連結し、Regexp として返します。
結果の Regexp は与えた pattern のどれかにマッチする場合にマッチするものになります。

//emlist[][ruby]{
p
Regexp.union(/a/, /b/, /c/) # => /(?-mix:a)|(?-mix:b)|(?-mix:c)/
//}...
...を与えても Regexp を生成します。
つまり、以下のように書くことができます。

//emlist[][ruby]{
arr = [/a/, /b/, /c/]
p
Regexp.union(arr) # => /(?-mix:a)|(?-mix:b)|(?-mix:c)/
# 1.8.7 より前は、以下のように書く必要があった
p
Regexp.union(*arr) # => /(?...
...//}

pattern
は Regexp または String で与えます。
String で与えた場合、それ自身と等しい文字列にマッチするものと解釈され、
エスケープされて結果の Regexp に組み込まれます。

//emlist[][ruby]{
p
Regexp.union("a", "?", "b") # => /a|\?|b/
p
Re...

Pathname#sub(pattern) {|matched| ... } -> Pathname (3314.0)

self を表現するパス文字列に対して sub メソッドを呼び出し、その結果を内 容とする新しい Pathname オブジェクトを生成し、返します。

...しい Pathname オブジェクトを生成し、返します。

@param pattern 置き換える文字列のパターンを指定します。

@param replace pattern で指定した文字列と置き換える文字列を指定します。

//emlist[例][ruby]{
require 'pathname'

p
ath1 = Pathname('/...
...usr/bin/perl')
p
ath1.sub('perl', 'ruby') #=> #<Pathname:/usr/bin/ruby>
//}

@see String#sub...

絞り込み条件を変える

<< < 1 2 3 4 5 ... > >>