I want to write a regex for the below PHP block and want to replace it with the actual image path.
<?php echo $imagePath; ?>
I have tried
str.replace(/<\?[=|php]?[\s\S]*?\?>/g, 'images/dir1/');
but it is replacing all other PHP blocks of the page also. I want a regex which replaces a particular PHP block.
phpcode fromjscode. This<?php echo $imagePath; ?>should be rendered, then you may do replacement