@ 2023-08-25T22:51:13Z <?php
$html = <<<'HTML'
<!DOCTYPE html>
<html>
<head>
<script>
let a=123; // comment // second comment
let b='https://www.bbc.co.uk';
// This is a comment
/* This is another comment */
// The following is not a comment
var src="//google.com";
toolbar.querySelector('.toolbar-format_italic').addEventListener('click', function () {
doInsertAtCursor(textarea, "///", "///");
doRefreshPreview(textarea);
}.bind(_self)); /* Comment */
Prism.languages.javascript = Prism.languages.extend(
regex: {
pattern: RegExp("((?:^|[^$\\w\\xA0-\\uFFFF.\"'\\])\\s]|\\b(?:return|yield))\\s*)/(?:(?:\\[(?:[^\\]\\\\\r\n]|\\\\.)*\\]|\\\\.|[^/\\\\\\[\r\n])+/[dgimyus]{0,7}|(?:\\[(?:[^[\\]\\\\\r\n]|\\\\.|\\[(?:[^[\\]\\\\\r\n]|\\\\.|\\[(?:[^[\\]\\\\\r\n]|\\\\.)*\\])*\\])*\\]|\\\\.|[^/\\\\\\[\r\n])+/[dgimyus]{0,7}v[dgimyus]{0,7})(?=(?:\\s|/\\*(?:[^*]|\\*(?!/))*\\*/)*(?:$|[\r\n,.;:})\\]]|//))"),
lookbehind: !0,
greedy: !0,
inside: {
"regex-source": {
pattern: /^(\/)[\s\S]+(?=\/[a-z]*$)/,
lookbehind: !0,
alias: "language-regex",
inside: Prism.languages.regex
}, "regex-delimiter": /^\/|\/$/, "regex-flags": /^[a-z]+$/
}
});
text = text.replace(/\/\/\/(.*?)\/\/\//g, "<em>$1<\/em>");
</script>
</head>
<body>
</body>
</html>
HTML;
libxml_use_internal_errors(true);
$dom = new DOMDocument;
$dom->loadHTML($html);
$scriptNodes = $dom->getElementsByTagName('script');
$pattern = <<<'EOD'
~
(?(DEFINE)
(?<squoted> ' [^'\n\\]*+ (?: \\. [^'\n\\]* )*+ ' )
(?<dquoted> " [^"\n\\]*+ (?: \\. [^"\n\\]* )*+ " )
(?<tquoted> ` [^`\\]*+ (?s: \\. [^`\\]*)*+ ` )
(?<quoted> \g<squoted> | \g<dquoted> | \g<tquoted> )
(?<scomment> // \N* )
(?<mcomment> /\* [^*]*+ (?: \*+ (?!/) [^*]* )*+ \*/ )
(?<comment> \g<scomment> | \g<mcomment> )
(?<pattern> / (?=[^\n/*]) [^\n/\\]*+ (?>\\.[^\n/\\]*)* / [gimuy]* )
)
(?=[[(:,=/"'`])
(?|
\g<quoted> (*SKIP)(*FAIL)
|
( [[(:,=] \s* ) (*SKIP) (?: \g<comment> \s* )*+ ( \g<pattern> )
|
( \g<pattern> \s* ) (?: \g<comment> \s* )*+
( \. \s* ) (?:\g<comment> \s* )*+ ([A-Za-z_]\w*)
|
\g<comment>
)
~x
EOD;
foreach ($scriptNodes as $scriptNode) {
$scriptNode->nodeValue = preg_replace($pattern, '$9${10}${11}', $scriptNode->nodeValue);
}
$html = $dom->saveHTML();
echo $html;
?>
Enable javascript to submit You have javascript disabled. You will not be able to edit any code.
Here you find the average performance (time & memory) of each version. A grayed out version indicates it didn't complete successfully (based on exit-code).
Version System time (s) User time (s) Memory (MiB) 8.4.13 0.011 0.011 18.20 8.4.12 0.010 0.010 20.55 8.4.11 0.014 0.007 22.73 8.4.10 0.005 0.008 18.20 8.4.9 0.015 0.006 19.18 8.4.8 0.012 0.008 18.91 8.4.7 0.014 0.006 18.24 8.4.6 0.013 0.008 20.88 8.4.5 0.012 0.009 20.69 8.4.4 0.012 0.009 17.92 8.4.3 0.004 0.004 20.88 8.4.2 0.012 0.006 20.18 8.4.1 0.000 0.009 22.24 8.3.26 0.007 0.016 17.10 8.3.25 0.011 0.010 19.22 8.3.24 0.015 0.006 17.00 8.3.23 0.011 0.009 17.05 8.3.22 0.013 0.006 17.79 8.3.21 0.013 0.008 18.69 8.3.20 0.006 0.003 16.88 8.3.19 0.005 0.005 17.78 8.3.18 0.012 0.008 16.86 8.3.17 0.010 0.000 17.66 8.3.16 0.010 0.007 19.44 8.3.15 0.003 0.006 17.39 8.3.14 0.006 0.012 17.63 8.3.13 0.006 0.013 18.84 8.3.12 0.009 0.000 21.13 8.3.11 0.008 0.008 20.94 8.3.10 0.009 0.009 16.94 8.3.9 0.014 0.004 26.77 8.3.8 0.003 0.006 17.97 8.3.7 0.003 0.013 18.93 8.3.6 0.012 0.009 17.13 8.3.5 0.018 0.000 18.76 8.3.4 0.011 0.004 22.00 8.3.3 0.011 0.004 19.47 8.3.2 0.009 0.000 24.18 8.3.1 0.000 0.008 24.66 8.3.0 0.008 0.000 26.16 8.2.29 0.012 0.006 20.75 8.2.28 0.005 0.004 18.98 8.2.27 0.003 0.015 17.65 8.2.26 0.006 0.003 18.91 8.2.25 0.011 0.011 18.91 8.2.24 0.003 0.006 17.41 8.2.23 0.010 0.000 22.58 8.2.22 0.003 0.006 24.06 8.2.21 0.016 0.004 26.77 8.2.20 0.000 0.009 16.88 8.2.19 0.007 0.007 16.88 8.2.18 0.007 0.007 17.13 8.2.17 0.011 0.004 19.41 8.2.16 0.016 0.000 22.96 8.2.15 0.003 0.006 25.66 8.2.14 0.003 0.005 24.66 8.2.13 0.008 0.000 26.16 8.2.12 0.006 0.003 22.34 8.2.11 0.000 0.011 20.69 8.2.10 0.003 0.007 22.63 8.2.9 0.006 0.006 18.09 8.1.33 0.012 0.007 22.18 8.1.32 0.009 0.013 16.53 8.1.31 0.004 0.004 18.60 8.1.30 0.004 0.004 16.94 8.1.29 0.003 0.007 30.84 8.1.28 0.007 0.011 25.92 8.1.27 0.008 0.000 24.66 8.1.26 0.008 0.000 26.35 8.1.25 0.000 0.009 28.09 8.1.24 0.000 0.010 20.90 8.1.23 0.010 0.007 18.93
preferences:dark mode live preview ace vim emacs key bindings
25.4 ms | 403 KiB | 5 Q