SyntaxFix
Write A Post
Hire A Developer
Questions
Rather than preg_replace, you could always use PHP's filter functions using the filter_var() function with FILTER_SANITIZE_STRING.
preg_replace
filter_var()
FILTER_SANITIZE_STRING