This question already has an answer here:
I am using simple_html_dom.inc.php 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.
</div>
Answer:
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.
Source from