Skip to content

Instantly share code, notes, and snippets.

Last active January 15, 2022 01:51
What would you like to do?
Multiple Replaces and Ternary Operator
# Sometimes URL is copied from a browser and arrives as
# 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 "", "") -replace "/edit", "":
($url -replace "client/", "")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment