$pattern = "/[^\d\w\s]/";
$replacement = "*";
$subject = "1 Main str, #5";
echo preg_replace($pattern, $replacement, $subject);
The ^ symbol negate a class. Right after this symbol we put the classes:
\d - digits
\w - words
\s - space
So, it reads as: "replace with * all the symbols from $subject, which are not digits, words and spaces".