use warnings; use strict; my $f = 'chap 89.9'; if($f=~m/chap.( |[a-z])*(\d+)(\.(\d+))?/i) { print " $2 $4\n"; }