Using pos to display pattern match positions. : pos « String « Perl






Using pos to display pattern match positions.

      
#!/usr/local/bin/perl 

$string = "Mississippi"; 
while ($string =~ /i/g) { 
    $position = pos($string); 
    print("matched at position $position\n"); 
} 

   
    
    
    
    
    
  








Related examples in the same category