replace(/(?<=<\?php)[\w\W]*(?=\?>)/g, " ");
I want to replace the words between <?php and ?>, but it doesn't work in JavaScript.
I have heard that JavaScript doesn't support regular expressions. How else can I solve this problem?
JavaScript doesn't support lookbehinds (the (?<= part) in regular expressions. You can just replace it with <?php ?> and drop the assertions, though:
replace(/<\?php.+?\?>/g, "<?php ?>");
<?php ?>that is available to JavaScript? Hopefully it has not been sent down to the client.