$r = 9; # or any single number my @arr = $string =~ /([^,|]+\,$r)/g;