php mb_ereg_match上的例外

I am using mb_ereg_match to validate that a domain name does not containe illegal characters.

I am using this regex:

'/:\/\/|www[.][a-zA-Zα-ωΑ-ΩάέύήίόώϋϊΐΰΆΈΏΊΎΌΉΫΪÀàÂâÆæÄäÇçÉéÈèÊêËëÎîÏïÔôŒœÖöÙùÛûÜüŸÿ0-9]+[.]|^[-]+|^[.]+|[-]+$|[.]+$|[-]{2,}|[.]{2,}|[^\w-.]|-[.]|[.]-/u'

Which as you can se by your self contain all the basic latin chars, nums, France's letters and the whole Greek alphabet.

My validation code is the following:

$utf8 = (mb_detect_encoding($value) == 'UTF-8') ? TRUE : FALSE;

if ($utf8){
    mb_internal_encoding('UTF-8');
    mb_regex_encoding('UTF-8');
    $matches = mb_ereg_match($pattern, $value);
}else{
    preg_match($pattern, $value, $matches);
}

I am trying to validate this:

'geoσσσrge.cσσσσσm.gr'

Here is the error I get:

mb_ereg_match(): mbregex compile err: empty range in char class

The error does not appear all the time. Usually it apears when it stays idle for a long time and after I refresh my page returns to normal.

I don't know how to handle this error or how to approche it in order to find the source of the problem.

Any suggestions?

\w through . is not a range it can understand. Escape the - or move the - to the start; [^\w-.].

$pattern = '/:\/\/|www[.][a-zA-Zα-ωΑ-ΩάέύήίόώϋϊΐΰΆΈΏΊΎΌΉΫΪÀàÂâÆæÄäÇçÉéÈèÊêËëÎîÏïÔôŒœÖöÙùÛûÜüŸÿ0-9]+[.]|^[-]+|^[.]+|[-]+$|[.]+$|[-]{2,}|[.]{2,}|[^\w\-.]|-[.]|[.]-/u';
$value = 'geoσσσrge.cσσσσσm.gr';

$utf8 = (mb_detect_encoding($value) == 'UTF-8') ? TRUE : FALSE;

if ($utf8){
    mb_internal_encoding('UTF-8');
    mb_regex_encoding('UTF-8');
    $matches = mb_ereg_match($pattern, $value);
}else{
    preg_match($pattern, $value, $matches);
}

or

$pattern = '/:\/\/|www[.][a-zA-Zα-ωΑ-ΩάέύήίόώϋϊΐΰΆΈΏΊΎΌΉΫΪÀàÂâÆæÄäÇçÉéÈèÊêËëÎîÏïÔôŒœÖöÙùÛûÜüŸÿ0-9]+[.]|^[-]+|^[.]+|[-]+$|[.]+$|[-]{2,}|[.]{2,}|[^-\w.]|-[.]|[.]-/u';
$value = 'geoσσσrge.cσσσσσm.gr';

$utf8 = (mb_detect_encoding($value) == 'UTF-8') ? TRUE : FALSE;

if ($utf8){
    mb_internal_encoding('UTF-8');
    mb_regex_encoding('UTF-8');
    $matches = mb_ereg_match($pattern, $value);
}else{
    preg_match($pattern, $value, $matches);
}