google sheets – How to extract specific words and separate them by commas?

I want to separate text from cells:

A1 = Bats, Cats, Mats, Rats E

A2 = Bats, Pattern, Rats W

A3 = Cats, Mats

A4 = Pattern

A5 = Mats

I want to remove Pattern and Mats from the rows and extract rest of the text separated by comma in one row in google sheet.

Like D1 = Bats, Cats, Rats E

D2= Bats, Rats W

D3 = Cats

D4 = ""

D5 = ""