2019-07-19 11:54
浏览 289


I am using for url extractor. The codes are working normaly without problem. But i am getting the following Warning from PHP7.3

Warning: preg_match(): Compilation failed: invalid range in character class at offset 4 in 1387

You can see the error line in this link: Error Line 1387

if (!preg_match("/^[\w-:]+$/", $tag)) {
    $node->_[HDOM_INFO_TEXT] = '<' . $tag . $this->copy_until('<>');
    if ($this->char==='<') {
        $this->link_nodes($node, false);
        return true;
    if ($this->char==='>') $node->_[HDOM_INFO_TEXT].='>';
    $this->link_nodes($node, false);
    $this->char = (++$this->pos<$this->size) ? $this->doc[$this->pos] : null; // next
    return true;

Do you have a solution for this problem? Thanks in advance.

  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 邀请回答

1条回答 默认 最新

  • dongmei8511
    dongmei8511 2019-07-19 11:56

    PHP 7.3 upgraded from PCRE to PCRE2. Which is much more strict on regular expressions. For example, you need to escape - between square brackets. And this is the problem in you regex.

    Changing it to /^[\w\-:]+$/ should solve your problem.

    点赞 1 评论