使用preg_match_all在字符串中显示无效字符

The correct pattern for the regular expression is:

$pattern = '/^[A-Z0-9,: \']+$/';

Meaning, only characters A-Z, numbers 0-9, a comma, a colon, and an apostrophe are allowed inside the text.

How do I display which characters are invalid by using only preg_match_all?

preg_match($pattern,$text,$match); // $match would return the valid match

What would be the correct pattern to match invalid characters (not A-Z, not 0-9, not a comma or colon or apostrophe)?

Your pattern is easy to negate. You can just use this inside preg_match_all (demo):

/[^A-Z0-9,: \']/