# perl -we '$x="somestring 12345 {ICMP}";$x=~/(.+({TCP}|{ICMP}))/ && print "$1\n"' somestring 12345 {ICMP}