Re: Warning: ereg() [function.ereg]: REG_ERANGE in ...
am 19.12.2007 23:17:15 von AnrDaemonGreetings, Good Man.
In reply to Your message dated Friday, December 14, 2007, 22:31:29,
>> I have written a function using ereg().
>>
>> function ValidateOpinion()
>> {
>> $reEmail = '^[A-Za-z0-9-.]{1,40}@[A-Za-z0-9-.]{1,70}$';
>> if (isset($_POST['Author']) && !empty($_POST['Author']) &&
>> isset($_POST['Email']) && ereg($reEmail, $_POST['Email']) &&
>> // HERE
>> PROBLEM
>> isset($_POST['Title']) && !IsVulgar($_POST['Title']) &&
>> isset($_POST['Contents']) && !empty($_POST['Contents']))
>> return true;
>> echo '
Opinion was not accepted.
\n';>> return false;
>> }
>>
>> I recive error:
>>
>> Warning: ereg() [function.ereg]: REG_ERANGE in
>> F:\Inetpub\wwwroot\StowarzyszenieIntegracja\Scripts.inc on line 51
>>
>> I don't know what's wrong.
>> Could you help me please? I have little experience.
>> /RAM/
> You can google to discover that you're using your '-' incorrectly:
> @[A-Za-z0-9-.]{1,70}
> If you are searching for the character '-', it needs to be mentioned
> first. Otherwise regex is going to look for a range, which is invalid
> (in your case, your range is set to "0-9-.")
Other way is to escape "-" character. It works for Perl RE, but I don't know
if the same is true for POSIX RE.
Also You SHOULD escape the dot all the way if You don't know what You doing.
--
Sincerely Yours, AnrDaemon