【发布时间】:2011-04-16 07:58:41
【问题描述】:
我正在尝试将 preg_match 检查从 url 检查更改为最小/最大 2-16chrs、破折号、空格和连字符可接受的用户名检查。我收到了这个错误
警告: preg_match() [function.preg-match]:编译失败:在偏移量 14 处没有可重复的内容
if(empty($string) || preg_match("#^([\w- ]{2,16}*(?:.[\w- ]{2,16}*)+):?(d+)?/?#i", $string))
查找 URL 的旧代码
if(empty($string) || preg_match("#^(http|https|ftp)://([A-Z0-9][A-Z0-9_-]*(?:.[A-Z0-9][A-Z0-9_-]*)+):?(d+)?/?#i", $string))
【问题讨论】:
标签: php regex preg-match