Reputation: 15925
I know there are many regex questions, but I don't know it well enough, nor could I find an answer explaining it well enough to derive the solution I'm trying to get.
In PHP, using
preg_replace($pattern,"",$data);
I'd like to allow all alphanumeric characters along with the minus, period, and underscore characters. What is the $pattern I need?
Upvotes: 1
Views: 4486
Reputation: 1186
Try this, i know this is not Regex...
$answer=iconv("UTF-8", "ISO-8859-1//IGNORE", $data);
Upvotes: 1
Reputation: 56497
maybe this can be tried:
$cleaner_input = trim(strip_tags($text));
Upvotes: -1
Reputation: 191789
$pattern = "/[^\w.-]/";
This is the negated character class of exactly the requirements you described.
Upvotes: 7