Multiple Replaces and Ternary Operator
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
# Sometimes URL is copied from a browser and arrives as | |
# https://consul.foo.com/client/ami_size/edit | |
# Othertimes URL is copied from Consul CLI and arrives as | |
# client/ami_size | |
# And I just need the actual key, being 'ami_size' for the script | |
$url = ($url -match "^https://") ? | |
($url -replace "https://consul.foo.com/client/", "") -replace "/edit", "": | |
($url -replace "client/", "") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment