+ 1

I need some help with Regex.... Javascript

I'm working on a code called "Code beautifier", but I have a problem with regex. code = code.replace(code.match(/(\/\/).+(?=(\<br\>\<\/br\>))/g), "<span class='comment'>" + code.match(/(\/\/).+(?=(\<br\>\<\/br\>))/g) + "</span>"); (Note: This is on a whole line, not separated) But it replaces only the furst occurence, not all the other, any suggestions how I could replace all occurences? Thank you!

5th Jan 2018, 1:38 PM
Milan Zanden
Milan Zanden - avatar
2 Respostas
+ 2
Check this and let me know if it works. https://code.sololearn.com/W6XlLn9uw68c/#js
9th Jan 2018, 8:35 AM
Ravi Chandra Enaganti
Ravi Chandra Enaganti - avatar
0
thank you! That 'll work!
9th Jan 2018, 10:32 AM
Milan Zanden
Milan Zanden - avatar