Splitting a string by newline character succeeds but removes the last character from the string
NickName:Denn Ask DateTime:2019-10-22T20:11:06

Splitting a string by newline character succeeds but removes the last character from the string

I am trying to split a string by newline character (\n) but it removes the last character from the string. How do I rectify this?

I have tried replacing the newline character with a pair of the same then splitting .. but not working.

var lines = str.split("\n");

The screenshot shows the difference between the raw array which I use to get the string at the console and the display in the table. As indicated by the marks, the last letters are missing:

The screenshot shows the difference between the raw array which I use to get the string at the console and the display in the table. As indicated by the marks, the last letters are missing

Copyright Notice:Content Author:「Denn」,Reproduced under the CC 4.0 BY-SA copyright license with a link to the original source and this disclaimer.
Link to original article:https://stackoverflow.com/questions/58504009/splitting-a-string-by-newline-character-succeeds-but-removes-the-last-character

More about “Splitting a string by newline character succeeds but removes the last character from the string” related questions

Splitting a string by newline character succeeds but removes the last character from the string

I am trying to split a string by newline character (\n) but it removes the last character from the string. How do I rectify this? I have tried replacing the newline character with a pair of the same

Show Detail

C string splitting with strtok by newline character error

I run into a problem with splitting a string by the new line character. The idea is that the server is sending to a client a message and the client splits the message by newline character in other 2

Show Detail

gsubbing a string with a pattern containing a newline character in Lua

Does string.gsub recognize the newline character in a string literal? I have a scenario in which I am trying to gsub a portion of a string indicated by a given operator from the start of the operat...

Show Detail

C: Trying to remove newline character from end of string

I'm trying to write a program that deletes the last newline from user input, ie the one generated when the user hits enter after having typed in a string. void func4() { char *string = malloc(

Show Detail

JavaScript Truncate String at the Last NewLine Character

I am trying to cut a string which is smaller than a certain size and cut it at the last encountered newline character (\n). So Far I have something like this which works and uses a space instead o...

Show Detail

File read newline from String while there is no newline character on the string

following image is what written in file, this is the code to write on a file. SecurityUtils class used here is to encode string to AES/CBC. public static boolean reWriteToFile(String str1, ...

Show Detail

Removing a string terminator and adding newline character in C

I was trying to make a function that removes the string terminator and adds a newline character instead to a string. The way i do it leads to a segfault. And i am unable to wrap my head around why my

Show Detail

Smalltalk, newline character

Does anybody know what's the newline delimiter for a string in smalltalk? I'm trying to split a string in separate lines, but I cannot figure out what's the newline character in smalltalk. ie. ...

Show Detail

Issue with removing newline character from unicode string in python

I have a piece of Unicode text. I wanted to remove all newline characters from the text before printing the output. My code looks something like this: input_string = u'\u3010JK\u3011\u9032\u5b66\u...

Show Detail

$ not matching position immediately before a newline that is the last character

$ is not matching a position immediately before a newline that is the last character. Ideally /1...$/ should match but match happens with the pattern /1....$/ which seems to be wrong. What could ...

Show Detail