trim then filter

trim the patterns before filter them