in reply to Regex matching next occurrence or to the end of line.

I am not completely sure what you want to achieve but using split capturing the separators using parentheses could help here:

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

gives you

$VAR1 = [ 'something in this string is a number. ', '${=NumberFormat "99999999"}', ' is a number. And another ', '${=CharFormat "X*"}', ' is ', '${=NumberFormat "9+"}', '.' ];

and the following if the curly brace is missing:

$VAR1 = [ 'something in this string is a number. ', '${=NumberFormat "99999999"}', ' is a number. And another ', '${=CharFormat "X*"}', ' is $=NumberFormat "9+"}.' ];

Replies are listed 'Best First'.
Re^2: Regex matching next occurrence or to the end of line.
by nabeenj (Initiate) on Feb 05, 2015 at 10:12 UTC

    Thank you for this. Really useful stuff which I am sure I'll be using as this work progresses.

    The script is matching a SOAP response to an expected SOAP response XML file. The expected SOAP response can have these sort of placeholders to match actual values (strings, numbers, dates) in the response that can be of variable length, and also values that may or may not be there - thus the requirement of the ${=CharFormat "X*"} placeholder. Much of the work is complete. Much appreciation and credit goes to the work by G. Wade Johnson in HTTPTest.

    Thanks again.