-3

I have a variable that contains a string with lots of line breaks.

myvariable = '
1234556788,3434343434\n
1244556788,7234343834\n
1234556788,4434343434\n
1234556784,8434343434\n
1234556782,9444343434\n
';

I need some way of removing just the first one without leaving a blank first line if possible.

So that this:

1234556788,3434343434\n
1244556788,7234343834\n
1234556788,4434343434\n
1234556784,8434343434\n
1234556782,9444343434\n

turns into this:

1244556788,7234343834\n
1234556788,4434343434\n
1234556784,8434343434\n
1234556782,9444343434\n

So it would remove the first line after the \n

How can I do this?

deszok
  • 145
  • 2
  • 14

1 Answers1

-1
myvariable = `1234556788,3434343434\n
1244556788,7234343834\n
1234556788,4434343434\n
1234556784,8434343434\n
1234556782,9444343434\n
`;
myvariable.substring(myvariable.indexOf('\n') + 2, myvariable.length);
Ivar
  • 6,138
  • 12
  • 49
  • 61
  • 2
    Note that template literals also preserve newlines, so `myvariable` now has two newlines every time. – Ivar Apr 20 '22 at 13:04