Mailing List Archive


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [tlug] Do you whitelist or blacklist utf-8? [SOLVED]



Hi Dave

Dave M G wrote:
TLUG,
function hasOnlyWhitelistedCharacters($string)
{
    // return TRUE to say "only whitelisted characters"
    return preg_match('/^[\p{L}\p{N}\p{Z}.@example.com/u', $string);
}

Be careful with the "." in your Regexp. The "." matches *any* character, so the above function will return TRUE for any String that contains at least one character, whatever it is!

Use "\." instead of "." to match a real "period".

Peter



Home | Main Index | Thread Index

Home Page Mailing List Linux and Japan TLUG Members Links