use strict;
my $str = '* LIST (\\HasChildren) "/" INBOX/Arkabit
* LIST (\\HasNoChildren) "/" "INBOX/Arkabit/Flora (SAP)"
* LIST (\\HasNoChildren) "/" INBOX/BRW
* LIST (\\HasNoChildren) "/" INBOX/Chiptronics
* LIST (\\HasNoChildren) "/" INBOX/CRMB1.COM
* LIST (\\Marked \\HasChildren) "/" INBOX/CVA
* LIST (\\HasNoChildren) "/" INBOX/CVA/Contabilista
* LIST (\\HasNoChildren) "/" INBOX/CVA/Maxflex
* LIST (\\HasNoChildren) "/" INBOX/Decorlux
* LIST (\\HasNoChildren) "/" INBOX/Fabiano
* LIST (\\HasNoChildren) "/" INBOX/Fabielle
* LIST (\\HasNoChildren) "/" INBOX/Gamma
* LIST (\\HasNoChildren) "/" INBOX/Integrate
* LIST (\\HasNoChildren) "/" INBOX/Kelli
* LIST (\\HasNoChildren) "/" INBOX/Laborclin
* LIST (\\HasNoChildren) "/" INBOX/Macrosul
* LIST (\\HasChildren) "/" INBOX/MadeiraMadeira
* LIST (\\HasNoChildren) "/" INBOX/MadeiraMadeira/BRW
* LIST (\\HasNoChildren) "/" INBOX/MadeiraMadeira/Eglo
* LIST (\\HasNoChildren) "/" "INBOX/MadeiraMadeira/Full Fit"
* LIST (\\HasNoChildren) "/" "INBOX/MadeiraMadeira/Glass Mosaic"
* LIST (\\Marked \\HasNoChildren) "/" INBOX/MadeiraMadeira/Luciin
* LIST (\\HasNoChildren) "/" INBOX/MadeiraMadeira/Rojemac
* LIST (\\HasNoChildren) "/" "INBOX/Mercado do Alarme"
* LIST (\\Marked \\HasChildren) "/" INBOX/Stuff
* LIST (\\HasNoChildren) "/" INBOX/Stuff/Importado
* LIST (\\Marked \\HasNoChildren) "/" INBOX/Stuff/Ita&APo-
* LIST (\\Marked \\HasNoChildren) "/" INBOX/Stuff/Literal
* LIST (\\HasChildren) "/" INBOX/Stuff/News
* LIST (\\HasNoChildren) "/" INBOX/Stuff/News/Linkedin
* LIST (\\HasNoChildren) "/" INBOX/Stuff/News/Microsoft
* LIST (\\HasNoChildren) "/" INBOX/Stuff/News/SAP
* LIST (\\Marked \\HasNoChildren) "/" INBOX/Stuff/Postman
* LIST (\\HasChildren) "/" INBOX/Stuff/PrimaERP
* LIST (\\HasNoChildren) "/" INBOX/Stuff/PrimaERP/Faturas
* LIST (\\Marked \\HasNoChildren) "/" INBOX/Stuff/VSOnline
* LIST (\\HasNoChildren) "/" "INBOX/Suporte | CRMSAP"
* LIST (\\HasNoChildren) "/" INBOX/Umbler
$ OK LIST completed.
';
my $regex = qr/\* LIST \((?<Markers>.*)\) \"\/\" (?<folder>.*?)$/mp;
if ( $str =~ /$regex/g ) {
print "Whole match is ${^MATCH} and its start/end positions can be obtained via \$-[0] and \$+[0]\n";
# print "Capture Group 1 is $1 and its start/end positions can be obtained via \$-[1] and \$+[1]\n";
# print "Capture Group 2 is $2 ... and so on\n";
}
# ${^POSTMATCH} and ${^PREMATCH} are also available with the use of '/p'
# Named capture groups can be called via $+{name}
Please keep in mind that these code samples are automatically generated and are not guaranteed to work. If you find any syntax errors, feel free to submit a bug report. For a full regex reference for Perl, please visit: http://perldoc.perl.org/perlre.html