Apparently it is also possible with regsubst, like this:

regsubst($hostname, '^(.{7})(.*)', '\1')

On 04/09/14 10:28, Martin Alfke wrote:
I assume that you can use the sprintf function (from Puppet core).

sprintf("%20.8s", "string test") #=> "            string t"

On 04 Sep 2014, at 11:19, Jonathan Gazeley <jonathan.gaze...@bristol.ac.uk> 
wrote:

Another dumb question, but I can't find what I'm looking for. Does Puppet have 
a function that's equivalent to the substr() function in Perl? I want to 
truncate arbitrary strings to 7 chars but I can't see how to do this with any 
of the built-in functions or functions in stdlib.

e.g. substr('hello', 4) returns 'hell'

Thanks,
Jonathan

--
You received this message because you are subscribed to the Google Groups "Puppet 
Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to puppet-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/puppet-users/54082EBE.4020509%40bristol.ac.uk.
For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "Puppet 
Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to puppet-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/puppet-users/54083343.90803%40bristol.ac.uk.
For more options, visit https://groups.google.com/d/optout.

Reply via email to