How do i prevent preg_replace() altering the content of () in following JavaScript-Snippet:
myVar.replace(/\u00AD/g, '');
This is my PHP function (I am not sure, which part is responsible):
$output = preg_replace('/true/', '!0', $output);
$output = preg_replace('/(?:(?:\/\*(?:[^*]|(?:\*+[^*\/]))*\*+\/)|(?:(?<!\:|\\\)\/\/[^"\'].*))/', '', $output);
$output = preg_replace('/ = /', '= ', $output);
$output = preg_replace('/\s*\n\s*/', '', $output);
$output = preg_replace('/([^A-Za-z0-9\_\$])\h/', '$1', $output);
$output = preg_replace('/\s?([\(\[{])\s?/', '$1', $output);
$output = preg_replace('/\s([\)\]}])/', '$1', $output);
$output = preg_replace('/;\n/', ';', $output);
$output = preg_replace('/;}/', '}', $output);
$output = preg_replace('/}\n/', '}', $output);
Thanks in advance …
You need to sign in to view this answers
Leave feedback about this