HEX
Server: Apache
System: Linux vpshost0650.publiccloud.com.br 4.4.79-grsec-1.lc.x86_64 #1 SMP Wed Aug 2 14:18:21 -03 2017 x86_64
User: bandeirantesbomb3 (10068)
PHP: 8.0.7
Disabled: apache_child_terminate,dl,escapeshellarg,escapeshellcmd,exec,link,mail,openlog,passthru,pcntl_alarm,pcntl_exec,pcntl_fork,pcntl_get_last_error,pcntl_getpriority,pcntl_setpriority,pcntl_signal,pcntl_signal_dispatch,pcntl_sigprocmask,pcntl_sigtimedwait,pcntl_sigwaitinfo,pcntl_strerror,pcntl_wait,pcntl_waitpid,pcntl_wexitstatus,pcntl_wifexited,pcntl_wifsignaled,pcntl_wifstopped,pcntl_wstopsig,pcntl_wtermsig,php_check_syntax,php_strip_whitespace,popen,proc_close,proc_open,shell_exec,symlink,system
Upload Files
File: //proc/self/root/opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/functions/split.rb
# Splits a string into an array using a given pattern.
# The pattern can be a string, regexp or regexp type.
#
# @example Splitting a String value
#
# ```puppet
# $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.
#
Puppet::Functions.create_function(:split) do
  dispatch :split_String do
    param 'String', :str
    param 'String', :pattern
  end

  dispatch :split_Regexp do
    param 'String', :str
    param 'Regexp', :pattern
  end

  dispatch :split_RegexpType do
    param 'String', :str
    param 'Type[Regexp]', :pattern
  end

  def split_String(str, pattern)
    str.split(Regexp.compile(pattern))
  end

  def split_Regexp(str, pattern)
    str.split(pattern)
  end

  def split_RegexpType(str, pattern)
    str.split(pattern.regexp)
  end
end