turns out that both of these sequences (previously working)
"`([\n\A;]+)\/\*(.+?)\*\/`ism" => "$1", // error
"`([\n\A;\s]+)//(.+?)[\n\r]`ism" =>"$1\n", // error
Now throw an error in PHP 7.3
Warning: preg_replace(): Compilation failed: escape sequence is invalid in character class offset 4
CONTEXT: consider this snipit, which removes CSS comments from a string
$buffer = ".selector {color:#fff; } /* some comment to remove*/";
$regex = array(
"`^([\t\s]+)`ism"=>'',
"`^\/\*(.+?)\*\/`ism"=>"",
"`([\n\A;]+)\/\*(.+?)\*\/`ism"=>"$1", // 7.3 error
"`([\n\A;\s]+)//(.+?)[\n\r]`ism"=>"$1\n", // 7.3 error
"`(^[\r\n]*|[\r\n]+)[\s\t]*[\r\n]+`ism"=>"\n"
);
$buffer = preg_replace(array_keys($regex),$regex,$buffer);
//returns cleaned up $buffer value with pure css and no comments
Refer to: https://stackoverflow.com/a/1581063/1293658
Q1 - Any ideas whats wrong with the REGEX in this case? This thread seems to suggest it's simply a misplaced backslash https://github.com/thujohn/twitter/issues/250
Q2 - Is this a PHP 7.3 bug or a problem with the REGEX sequence in this code?