0

这是我下面列出的原始代码。

if(ereg($pattern,strtolower($this->get_domain())) && !ereg("^-|-$",strtolower($this->get_domain())) && !preg_match("/--/",strtolower($this->get_domain()))){

这是错误

已弃用:函数 ereg() 已弃用

然后我用下面的替换了ereg preg_match。我收到此错误

if(preg_match($pattern,strtolower($this->get_domain())) && !preg_match("^-|-$",strtolower($this->get_domain())) && !preg_match("/--/",strtolower($this->get_domain()))){

警告:preg_match() [function.preg-match]:没有找到结束分隔符 '^'

我试图把/之前^和之后,$但仍然没有运气。我可以从可能知道如何解决此错误的人那里获得一些帮助。

4

1 回答 1

0

为您的正则表达式添加分隔符:

$pattern = "/^[a-z".$idn."0-9\-]{3,}$/";// same for "/^[a-z0-9\-]{3,}$/"
//   here __^             and here __^
if(preg_match($pattern, strtolower($this->get_domain())) && 
  !preg_match("/^-|-$/",strtolower($this->get_domain())) && 
  //         __^   __^
  !preg_match("/--/", strtolower($this->get_domain()))){
于 2014-02-04T08:09:52.807 回答