I was using the following code to detect all the javadoc comments in the pre elements to replace them with a color of my choice.
<script type="text/javascript">
var arr = document.getElementsByTagName("pre");
for (var i=0; i<arr.length; i++){
arr[i].innerHTML = arr[i].innerHTML.replace(/\t/g, ' ');
arr[i].innerHTML = arr[i].innerHTML.replace(/</g, '<');
arr[i].innerHTML = arr[i].innerHTML.replace(/>/g, '>');
arr[i].innerHTML = arr[i].innerHTML.replace(/\\/*\*\*([^\*]|\*(?!/))*\\*/g, '<font color="#3F5FBF">' + $& + '</font>');
}
</script>
but it gives me the following error.
Uncaught SyntaxError: Unexpected token ILLEGAL
EDIT: changed the code to
<script type="text/javascript">
var arr = document.getElementsByTagName("pre");
for (var i=0; i<arr.length; i++){
arr[i].innerHTML = arr[i].innerHTML.replace(/\t/g, ' ');
arr[i].innerHTML = arr[i].innerHTML.replace(/</g, '<');
arr[i].innerHTML = arr[i].innerHTML.replace(/>/g, '>');
var reg = /\\\/*\*\*([^\*]|\*(?!\/))*\\*/;
var cds = arr[i].innerHTML.match(reg);
for (var j=0; j<cds.length; j++){
arr[i].innerHTML = arr[i].innerHTML.replace(cds[j], '<font color="#3F5FBF">' + cds[j] + '</font>');
}
}
prettyPrint();
</script>
But the error changes to
Uncaught TypeError: Cannot read property 'length' of null start-ahead.html:234
(anonymous function)
\after/\\/*. Look at the syntax highlighter, your escape is wrong.(?!/). Replace it with(?!\/)start-ahead.html:234