fork download
  1. #!/usr/bin/perl
  2. use strict;
  3. use warnings;
  4.  
  5. my $text = "{value1}+{value2}-{value3}*{value...n}";
  6.  
  7. if ($text =~ /\A ({ [^{}]* }) (?: [\/+*-] (?1))* \z/x) {
  8. while($text =~ / { [^{}]* } | [\/+*-] /gx) {
  9. print "$&\n";
  10. }
  11. }
  12.  
Success #stdin #stdout #stderr 0.01s 5580KB
stdin
Standard input is empty
stdout
{value1}
+
{value2}
-
{value3}
*
{value...n}
stderr
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.