Reputation: 638
I use CI_Minifier and have problems after I have updated my PHP.
Now I receive an error when I use the preg_match
function.
if (!preg_match("/^[\w-:]+$/", $tag)) { #error line
$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;
}
The error is:
Compilation failed: invalid range in character class at offset 4
Upvotes: 3
Views: 10092
Reputation: 91488
Escape the hyphen:
if (!preg_match("/^[\w\-:]+$/", $tag)) {
or put it at the beginning of character class:
if (!preg_match("/^[-\w:]+$/", $tag)) {
or at the end:
if (!preg_match("/^[\w:-]+$/", $tag)) {
Upvotes: 12