how to replace spaces and newlines together with additional closing code ;
in javascript?
function main(){
var a = 'hello'
console.log(a)
}
console.log(main.toString().replace(/[n ]/g,''))
output
functionmain(){vara='hello'console.log(a)}
I want
function main(){var a='hello';console.log(a);}
2
Answers
maybe this is correct
Based on your requirements, I think this regex can do the job:
1- part one :
2- part two:
3- part three: