I need to convert this java snip it of code that came from a .jar file to a php function with all regex. (Please see attached file). The java file basically compresses html code by removing unneeded tags, characters and white spaces.
I need to convert all the java regex and/or functions to php regex. Some of it may already be compatible with php and some may not be. I'm looking for one simple function that does a preg_replace and utilizes all the regex in the attached java file. This job is a lot of copy and pasting and converting java regex to php compatible regex. If there are functions that have if statements for different tags, we just need to replace that with a regex that handles the process.
The end product should be a simple php function like the one below with all the regex from the java file and converted for php.
EXAMPLE:
function html_compressor($html) {
$search = array(
'regex',
'regex',
);
$replace = array(
'$1',
'$1'
);
$buffer = preg_replace($search, $replace, $html);
return $html;
}
You should be able to pass html data through this function and you should be able to get 100% for the html minify section on [login to view URL] when scanning your html file/website. The html should still validate and work correctly. I can help by testing the function. please comment the code for each regex so I know what each one is responsible for.
Skills needed:
Java, php and regular expressions.