From d84af6b4fea0c67f69f29b4afddca0962edccab1 Mon Sep 17 00:00:00 2001 From: Jaimin Pandya Date: Sun, 6 Mar 2022 18:33:24 -0800 Subject: [PATCH] adding solution to preg_replace error --- components/CSS.php | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/components/CSS.php b/components/CSS.php index 6fef17a..f088fb7 100644 --- a/components/CSS.php +++ b/components/CSS.php @@ -165,16 +165,8 @@ protected function process(array $files) protected function removeCssComments(&$code) { if (true === $this->view->removeComments) { - - //https://stackoverflow.com/questions/1581049/preg-replace-out-css-comments - $regex = array( - "`^([\t\s]+)`ism"=>'', - "`^\/\*(.+?)\*\/`ism"=>"", - "`([\n\A;]+)\/\*(.+?)\*\/`ism"=>"$1", - "`([\n\A;\s]+)//(.+?)[\n\r]`ism"=>"$1\n", - "`(^[\r\n]*|[\r\n]+)[\s\t]*[\r\n]+`ism"=>"\n" - ); - $code = preg_replace(array_keys($regex),$regex,$code); + //https://stackoverflow.com/a/3984887 + $code = preg_replace( '!/\*[^*]*\*+([^/][^*]*\*+)*/!' , '' , $code ); } }