Cleanest filter for "if tid has X then do Y otherwise just PASS IT ON"

Just for completeness see How to Remove N repeating, leading or trailing characters/strings for another approach that can be used, using the spilt and join on a given character or string.