Using pos to display pattern match positions. : pos « String « Perl
- Perl
- String
- pos
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