Zero width loop : Loop « Regular Expression « Perl






Zero width loop

   


#!/usr/bin/perl
use warnings;
use strict;

my $text = "this is a test";
while ($text =~ /(?=(.))/g) {
    print "[$1]";
}

   
    
    
  








Related examples in the same category

1.Iterate over matches with foreach and $_ and nested foreach
2.Iterate over matches with foreach and $_ and nested while loop
3.Iterate over matches with while and $1
4.A program that loops using a pattern.