#!/usr/bin/perluse strict;use warnings; my $text = "{value1}+{value2}-{value3}*{value...n}"; if ($text =~ /\A ({ [^{}]* }) (?: [\/+*-] (?1))* \z/x) { while($text =~ / { [^{}]* } | [\/+*-] /gx) { print "$&\n"; }}
Standard input is empty
{value1} + {value2} - {value3} * {value...n}
Unescaped left brace in regex is deprecated here (and will be fatal in Perl 5.32), passed through in regex; marked by <-- HERE in m/\A ({ <-- HERE [^{}]* }) (?: [/+*-] (?1))* \z/ at prog.pl line 7.
The brand new service which powers Ideone!
Widget for compiling and running the source code in a web browser!