To simplify it’s:
preg_replace ( $pattern , $replacement , $subject] )
This function, “Searches subject for matches to pattern and replaces them with replacement.”, as described here:
https://php.net/manual/en/function.preg-replace.php
So, combining them would look something like this:
$regex = “Your regex pattern goes here”;
preg_replace($regex, “”, $post->post_content)));
The pattern is a regex pattern if that wasn’t obvious. You may need an expert or to learn a bit about regex and then play with it until you get the desired result.
I just found this tool, and bookmarked for myself for the next time I need a regex pattern. But, I haven’t used it yet. Maybe it’ll help though.
https://regex101.com/