my $_sensor_type = 'I2600*&^_A8699()^%#@C9800&*%A96'; my $type = ($_sensor_type =~ /[a-z]+([0-9]+)/i)[0]; print "$type\n"; #prints 2600 #so what happens if the match and consequent slice fails? $type ||= "some default"; #or check for undef