I want to replace empty lines in my string with an iterating number
e.g. replace
String:
"My first line
My second line
My third line"
with
"
1
My first line
2
My second line
3
My third line"
I can match and replace these lines using
var newstring = TestVar.replace (/(^|\n\n)/g, "\nhello\n");
However I'm struggling to add a function that will add an iterating number to each one.
Can you help?
TIA,
Gids