my $string = "Programm Version 1.2.3 next relase foo bar" if ( $string =~ m/ ( [\d.]+ ) /x ) { ... } if ( $string =~ m/ Version ( [\d.]+ ) /x { ... }