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]



On 24 February 2011 12:19, Peter Brandt <me387511@example.com> wrote:

> Dave M G wrote:
>
>>     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!

His . is inside a character class, where it becomes literal. The proof
is in the (irb) pudding:

>> 'f' =~ /[.]/
=> nil
>> '.' =~ /[.]/
=> 0


-- 
Cheers,
Josh


Home | Main Index | Thread Index

Home Page Mailing List Linux and Japan TLUG Members Links