Reputation: 3
Could somebody please help out with this line? How to modify it so it only allows a-Z, 0-9? Thanks.
if (preg_match('~[<>&"\'=\\\]~', preg_replace('~&#(?:\\d{1,7}|x[0-9a-fA-F]{1,6});~', '', $context['checked_username'])) != 0 || $context['checked_username'] == '_' || $context['checked_username'] == '|' || strpos($context['checked_username'], '[code') !== false || strpos($context['checked_username'], '[/code') !== false) $context['valid_username'] = false;
Upvotes: 0
Views: 362
Reputation: 10246
following code checks [[:alnum:]] (alnum
stands for alpha numeric)
if (!preg_match("/^[[:alnum:]]+$/", $context['checked_username']))
{
$context['valid_username'] = false;
}
Upvotes: 0