@arr = split(/\|/, $string); $#arr1 = -1; @arr1 = grep { /reg exp/ } @arr;