Skip to content

Instantly share code, notes, and snippets.

@natemccurdy
Last active March 21, 2019 19:27
Show Gist options
  • Save natemccurdy/9d629a018070b7f420171801f808a857 to your computer and use it in GitHub Desktop.
Save natemccurdy/9d629a018070b7f420171801f808a857 to your computer and use it in GitHub Desktop.
different ways to slice a string in Puppet
#
# All of these examples should return 'bar'.
#
$string = 'foo@bar'
notice($string.split('@')[-1])
notice($string.regsubst(/\A.+@(.+)\Z/, '\1'))
with() || {
$string =~ /\A.+@(.+)\Z/
notice($1)
}
notice($string.match(/\A.+@(.+)\Z/)[1])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment