Last active
March 21, 2019 19:27
-
-
Save natemccurdy/9d629a018070b7f420171801f808a857 to your computer and use it in GitHub Desktop.
different ways to slice a string in Puppet
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# | |
# 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