Sha256: 9ca444163fda956577f9eadc4ea19b15e0921b3fd3dea35410baca4cb7931f5f

Contents?: true

Size: 851 Bytes

Versions: 30

Compression:

Stored size: 851 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, '[.:]')

`$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

30 entries across 30 versions & 1 rubygems

Version Path
puppet-4.2.0-x64-mingw32 lib/puppet/parser/functions/split.rb
puppet-4.1.0 lib/puppet/parser/functions/split.rb
puppet-4.1.0-x86-mingw32 lib/puppet/parser/functions/split.rb
puppet-4.1.0-x64-mingw32 lib/puppet/parser/functions/split.rb
puppet-4.0.0 lib/puppet/parser/functions/split.rb
puppet-4.0.0-x86-mingw32 lib/puppet/parser/functions/split.rb
puppet-4.0.0-x64-mingw32 lib/puppet/parser/functions/split.rb
puppet-4.0.0.rc1 lib/puppet/parser/functions/split.rb
puppet-4.0.0.rc1-x86-mingw32 lib/puppet/parser/functions/split.rb
puppet-4.0.0.rc1-x64-mingw32 lib/puppet/parser/functions/split.rb