Tengo el siguiente código y estoy tratando de reemplazar la expresión regular con otro texto, pero no funciona ninguna sugerencia. estoy haciendo mal?
const regex = /\?/g; let p = document.querySelectorAll('.test'); p.forEach((pa) => { pa.style.color = 'red'; pa.innerHTML.replace(regex, 'test'); }); <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Document</title> </head> <body> <p class="test">This one was, hopefully, quite straightforward although? it did get a bit more complicated as a? previous exercise had created multiple paragraph tags on the page. It's a good bit of string! manipulation practice too.Got your own solution for this?;</p> </body> <script src="app2.js"></script> </html>Como mencionó Ivar, debe configurar el archivo innerhtml.
pa.innerHTML = pa.innerHTML.replace(regex, 'test');
const regex = /\?/g; let p = document.querySelectorAll('.test'); p.forEach((pa) => { pa.style.color = 'red'; pa.innerHTML = pa.innerHTML.replace(regex, 'test'); }); <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Document</title> </head> <body> <p class="test">This one was, hopefully, quite straightforward although? it did get a bit more complicated as a? previous exercise had created multiple paragraph tags on the page. It's a good bit of string! manipulation practice too.Got your own solution for this?;</p> </body> <script src="app2.js"></script> </html>