Skip to content

Instantly share code, notes, and snippets.

@jakauppila
Last active June 22, 2017 21:44
Show Gist options
  • Save jakauppila/8b00a82aa19dc6506b2fde2a1c9ba5c7 to your computer and use it in GitHub Desktop.
Save jakauppila/8b00a82aa19dc6506b2fde2a1c9ba5c7 to your computer and use it in GitHub Desktop.
Groovy String Interpolation Evaluation
// This value is being read in from an external file, which is why we can't perform the interpolation at runtime
myString = 'https://${first}:${second}@foobar.com'
// These are the two variables I want to substitute
first = 'hello'
second = 'world'
println evaluate(/"$myString"/)
// Expected
// 'https://hello:world@foobar.com'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment