2 deleted 523 characters in body
source | link
mysum = a c^2 Cos[2 t ω] (Quantity[-(1/2), "ElectricConstant"]) + 
        a b c Cos[t ω] (Quantity[-I, "ElectricConstant"]) + 
        a b c Cos[t ω] (Quantity[I, "ElectricConstant"]) + 
        a c^2 (Quantity[1/2, "ElectricConstant"]) + 
        a b^2 (Quantity[1, "ElectricConstant"]) + 
        a b c (Quantity[2, "ElectricConstant"]) Sin[t ω] + 
        a c^2 (Quantity[-(I/4), "ElectricConstant"]) Sin[2 t ω] + 
        a c^2 (Quantity[I/4, "ElectricConstant"]) Sin[2 t ω];

DeleteCases[mysum, x_ /; Not[FreeQ[x, t]]]

or

DeleteCases[mysum, Except[_?(FreeQ[#, t] &)]]

both give

(* a c^2 (Quantity[1/2, "ElectricConstant"]) + a b^2 (Quantity[1, "ElectricConstant"]) *)
mysum = a c^2 Cos[2 t ω] (Quantity[-(1/2), "ElectricConstant"]) + 
        a b c Cos[t ω] (Quantity[-I, "ElectricConstant"]) + 
        a b c Cos[t ω] (Quantity[I, "ElectricConstant"]) + 
        a c^2 (Quantity[1/2, "ElectricConstant"]) + 
        a b^2 (Quantity[1, "ElectricConstant"]) + 
        a b c (Quantity[2, "ElectricConstant"]) Sin[t ω] + 
        a c^2 (Quantity[-(I/4), "ElectricConstant"]) Sin[2 t ω] + 
        a c^2 (Quantity[I/4, "ElectricConstant"]) Sin[2 t ω];

DeleteCases[mysum, x_ /; Not[FreeQ[x, t]]]

or

DeleteCases[mysum, Except[_?(FreeQ[#, t] &)]]

both give

(* a c^2 (Quantity[1/2, "ElectricConstant"]) + a b^2 (Quantity[1, "ElectricConstant"]) *)
DeleteCases[mysum, x_ /; Not[FreeQ[x, t]]]

or

DeleteCases[mysum, Except[_?(FreeQ[#, t] &)]]

both give

(* a c^2 (Quantity[1/2, "ElectricConstant"]) + a b^2 (Quantity[1, "ElectricConstant"]) *)
1
source | link

mysum = a c^2 Cos[2 t ω] (Quantity[-(1/2), "ElectricConstant"]) + 
        a b c Cos[t ω] (Quantity[-I, "ElectricConstant"]) + 
        a b c Cos[t ω] (Quantity[I, "ElectricConstant"]) + 
        a c^2 (Quantity[1/2, "ElectricConstant"]) + 
        a b^2 (Quantity[1, "ElectricConstant"]) + 
        a b c (Quantity[2, "ElectricConstant"]) Sin[t ω] + 
        a c^2 (Quantity[-(I/4), "ElectricConstant"]) Sin[2 t ω] + 
        a c^2 (Quantity[I/4, "ElectricConstant"]) Sin[2 t ω];

DeleteCases[mysum, x_ /; Not[FreeQ[x, t]]]

or

DeleteCases[mysum, Except[_?(FreeQ[#, t] &)]]

both give

(* a c^2 (Quantity[1/2, "ElectricConstant"]) + a b^2 (Quantity[1, "ElectricConstant"]) *)