#!/usr/bin/perl use strict; my $s = 'bla-x3k-bla'; my $regex = "-(.+)-"; $s=~/$regex/; print $1."\n";