fork download
  1. #!/usr/bin/perl
  2. use warnings;
  3. use strict;
  4.  
  5. my $text = "X4IitemX6Nabc123";
  6. if ($text =~ m/^X(?<namelen>[0-9]+)I(?<name>(??{".{".$^N."}"}))X(?<numlen>[0-9]+)N(?<num>.+)$/) {
  7. print $text . ": PASS!\n";
  8. } else {
  9. print $text . ": FAIL!\n"
  10. }
  11. # -> X4IitemX6Nabc123: PASS!
Success #stdin #stdout 0.01s 5520KB
stdin
Standard input is empty
stdout
X4IitemX6Nabc123: PASS!