I am currently making a HTML form upload system. I am trying to read the HTML file using fs.readFile
then I'm attempting to replace the action attribute of the form tag with "/form/" + form._id
, so that the form makes POST requests to this route.
I am having trouble making a regex to find the action attribute. This is what I have until now:
var newData = data.replace(/action(? *)=(? *)("|')(?=.*)("|')/g, 'action="/form/' + form._id + '/");
I know the regex is wrong. I really couldn't understand how it works. If you have an answer please write and explanation too if you don't mind. Thank you in advance.