Given the following Groovy code switch statement:
def vehicleSelection = "Car Selected: Toyota"
switch (vehicleSelection) {
case ~/Car Selected: (.*)/:
println "The car model selected is " + ??[0][1]
}
Is it possible to extract the word “Toyota” without defining a new (def) variable?
This is possible using the
lastMatchermethod added toMatcherby Groovy: