use strict; use warnings; use Data::Dumper; my $string_exp = 'something in this string is a number. ${=NumberFormat "99999999"} is a number. And another ${=CharFormat "X*"} is ${=NumberFormat "9+"}.'; my @pieces = split /(\$\{.*?\})/, $string_exp; print Dumper \@pieces;