c:\@Work\Perl>perl -wMstrict -le "use Data::Dump qw(pp); ;; my $qr_string = q((?:\G(\w)\W{2}(\w))*); my $qr = qr[$qr_string]; ;; for my $s ('', qw(a--b c--dE--F g--hI--Jk--l)) { my @caps = $s =~ /$qr/g; print qq{'$s' -> }, pp \@caps; } " '' -> [undef, undef] 'a--b' -> ["a", "b", undef, undef] 'c--dE--F' -> ["c", "d", "E", "F", undef, undef] 'g--hI--Jk--l' -> ["g", "h", "I", "J", "k", "l", undef, undef] c:\@Work\Perl>perl -wMstrict -le "use Data::Dump qw(pp); ;; my $qr_string = q((?:(\w)\W{2}(\w))*); my $qr = qr[$qr_string]; ;; for my $s ('', qw(a--b c--dE--F g--hI--Jk--l)) { my @caps = $s =~ /$qr/g; print qq{'$s' -> }, pp \@caps; } " '' -> [undef, undef] 'a--b' -> ["a", "b", undef, undef] 'c--dE--F' -> ["E", "F", undef, undef] 'g--hI--Jk--l' -> ["k", "l", undef, undef] #### c:\@Work\Perl>perl -wMstrict -le "use Data::Dump qw(pp); ;; my $qr_string = q((?:\G(\w)\W{2}(\w))); my $qr = qr[$qr_string]; ;; for my $s ('', qw(a--b c--dE--F g--hI--Jk--l)) { my @caps = $s =~ /$qr/g; print qq{'$s' -> }, pp \@caps; } " '' -> [] 'a--b' -> ["a", "b"] 'c--dE--F' -> ["c", "d", "E", "F"] 'g--hI--Jk--l' -> ["g", "h", "I", "J", "k", "l"] c:\@Work\Perl>perl -wMstrict -le "use Data::Dump qw(pp); ;; my $qr_string = q((?:(\w)\W{2}(\w))); my $qr = qr[$qr_string]; ;; for my $s ('', qw(a--b c--dE--F g--hI--Jk--l)) { my @caps = $s =~ /$qr/g; print qq{'$s' -> }, pp \@caps; } " '' -> [] 'a--b' -> ["a", "b"] 'c--dE--F' -> ["c", "d", "E", "F"] 'g--hI--Jk--l' -> ["g", "h", "I", "J", "k", "l"] #### c:\@Work\Perl>perl -wMstrict -le "use Data::Dump qw(dd); ;; my $s = 'aBcDeFg'; ;; my @captures = $s =~ m{ (B) | (D) | (F) }xmsg; dd \@captures; " ["B", undef, undef, undef, "D", undef, undef, undef, "F"] #### c:\@Work\Perl>perl -wMstrict -le "use Data::Dump qw(dd); ;; my $qr_string = q((?:(\w)\W{2}(\w))*); my $qr = qr[$qr_string+]; ;; my $s = '%%%%'; print 'MATCH!!!' if $s =~ /$qr/g; dd \@-; ;; my @captures = $s =~ /$qr/g; dd \@captures; " MATCH!!! [0] [undef, undef, undef, undef, undef, undef, undef, undef] #### c:\@Work\Perl>perl -wMstrict -le "use Data::Dump qw(pp); ;; my $qr_string = q((?:(\w)\W{2}(\w))*); my $qr = qr[$qr_string]; ;; my $s = '%%%%'; ;; print 'match @ offset ', $-[0], ' ($1, $2)==', pp $1, $2 while $s =~ /$qr/g; ;; my @captures = $s =~ /$qr/g; pp \@captures; " match @ offset 0 ($1, $2)==(undef, undef) match @ offset 1 ($1, $2)==(undef, undef) match @ offset 2 ($1, $2)==(undef, undef) match @ offset 3 ($1, $2)==(undef, undef) match @ offset 4 ($1, $2)==(undef, undef) [undef, undef, undef, undef, undef, undef, undef, undef, undef, undef]