String s = "abc";
switch(s){
case { it =~ /b/ }:
println 'string has a "b" in it'
break;
case ~/abc/:
println 'matched'
break;
}
switch(s){
case { it =~ /e/ }:
println 'string has a "e" in it'
break;
case ~/abc/:
println 'matched "abc"'
break;
}
U3RyaW5nIHMgPSAiYWJjIjsKCnN3aXRjaChzKXsKICBjYXNlIHsgaXQgPX4gL2IvIH06CiAgICBwcmludGxuICdzdHJpbmcgaGFzIGEgImIiIGluIGl0JwogICAgYnJlYWs7CiAgY2FzZSB+L2FiYy86CiAgICBwcmludGxuICdtYXRjaGVkJwogICAgYnJlYWs7Cn0KCnN3aXRjaChzKXsKICBjYXNlIHsgaXQgPX4gL2UvIH06CiAgICBwcmludGxuICdzdHJpbmcgaGFzIGEgImUiIGluIGl0JwogICAgYnJlYWs7CiAgY2FzZSB+L2FiYy86CiAgICBwcmludGxuICdtYXRjaGVkICJhYmMiJwogICAgYnJlYWs7Cn0=