$s = "Test-01-xxx"; if ($s =~ /(.*?)-(\d\d)-(.*)/g) { print "The string was split into :\n" print "Left part : $1\n"; print "Number part : $2\n"; print "Right part : $3\n"; }