I have this code:
$('#myTextArea').val($('#myTextArea').val().replace(linesText[4] + '\n', ""));
and it works fine. The problem is in this case:
$('#myTextArea').val() = "\n\n33333333333\n\n\n"
and linesText is this array:
0: ""
1: ""
2: "33333333333"
3: ""
4: ""
5: ""
What I want to happen: $('#myTextArea').val() to become "\n\n33333333333\n\n".
What happens:
$('#myTextArea').val()
becomes
"\n33333333333\n\n".
This happens because I actually replace "" + "\n" with "" and it takes the first "\n". I want to take the fourth. How to fix this? This works when linesText's fields aren't empty.