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)?