How can I modify this existing preg_replace to only allow numbers?
JavaScript
x
function __cleanData($c)
{
return preg_replace("/[^A-Za-z0-9]/", "",$c);
}
Advertisement
Answer
I think you’re saying you want to remove all non-numeric characters. If so, D
means “anything that isn’t a digit”:
JavaScript
preg_replace('/D/', '', $c)