4 module Puppet::Parser::Functions
5 newfunction(:grep, :type => :rvalue, :doc => <<-DOC
6 This function searches through an array and returns any elements that match
7 the provided regular expression.
11 grep(['aaa','bbb','ccc','aaaddd'], 'aaa')
17 Note that since Puppet 4.0.0, the filter() function in Puppet can do the same:
19 ['aaa', 'bbb', 'ccc', 'aaaddd']. filter |$x| { $x =~ 'aaa' }
23 if arguments.size != 2
24 raise(Puppet::ParseError, "grep(): Wrong number of arguments given #{arguments.size} for 2")
28 pattern = Regexp.new(arguments[1])
34 # vim: set ts=2 sw=2 et :