Sha256: 425a97a203e9cb100d6f498f012c5498aa240b0d7b036e150a424a164ea6a464

Contents?: true

Size: 859 Bytes

Versions: 54

Compression:

Stored size: 859 Bytes

Contents

module Puppet::Parser::Functions

  newfunction(
  :split, :type => :rvalue,
  :arity => 2,

    :doc => "\
Split a string variable into an array using the specified split regexp.

*Example:*

    $string     = 'v1.v2:v3.v4'
    $array_var1 = split($string, ':')
    $array_var2 = split($string, '[.]')
    $array_var3 = split($string, Regexp['[.:]'])

`$array_var1` now holds the result `['v1.v2', 'v3.v4']`,
while `$array_var2` holds `['v1', 'v2:v3', 'v4']`, and
`$array_var3` holds `['v1', 'v2', 'v3', 'v4']`.

Note that in the second example, we split on a literal string that contains
a regexp meta-character (.), which must be escaped.  A simple
way to do that for a single character is to enclose it in square
brackets; a backslash will also escape a single character.") do |args|

    function_fail(['split() has been converted to 4x API'])
  end
end

Version data entries

54 entries across 54 versions & 2 rubygems

Version Path
puppet-retrospec-1.5.0 vendor/gems/puppet-4.5.2/lib/puppet/parser/functions/split.rb
puppet-retrospec-1.4.1 vendor/gems/puppet-4.5.2/lib/puppet/parser/functions/split.rb
puppet-retrospec-1.4.0 vendor/gems/puppet-4.5.2/lib/puppet/parser/functions/split.rb
puppet-retrospec-1.3.2 vendor/gems/puppet-4.5.2/lib/puppet/parser/functions/split.rb
puppet-retrospec-1.3.1 vendor/gems/puppet-4.5.2/lib/puppet/parser/functions/split.rb
puppet-retrospec-1.3.0 vendor/gems/puppet-4.5.2/lib/puppet/parser/functions/split.rb
puppet-4.7.1 lib/puppet/parser/functions/split.rb
puppet-4.7.1-x86-mingw32 lib/puppet/parser/functions/split.rb
puppet-4.7.1-x64-mingw32 lib/puppet/parser/functions/split.rb
puppet-4.7.1-universal-darwin lib/puppet/parser/functions/split.rb
puppet-retrospec-1.2.1 vendor/gems/puppet-4.5.2/lib/puppet/parser/functions/split.rb
puppet-retrospec-1.2.0 vendor/gems/puppet-4.5.2/lib/puppet/parser/functions/split.rb
puppet-4.7.0 lib/puppet/parser/functions/split.rb
puppet-4.7.0-x86-mingw32 lib/puppet/parser/functions/split.rb
puppet-4.7.0-x64-mingw32 lib/puppet/parser/functions/split.rb
puppet-4.7.0-universal-darwin lib/puppet/parser/functions/split.rb
puppet-4.6.2 lib/puppet/parser/functions/split.rb
puppet-4.6.2-x86-mingw32 lib/puppet/parser/functions/split.rb
puppet-4.6.2-x64-mingw32 lib/puppet/parser/functions/split.rb
puppet-4.6.2-universal-darwin lib/puppet/parser/functions/split.rb