Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to split String based on \r\n [duplicate]

We are Developing phonegap application.We get Data form CSV file. It's look like this We getting data like this

We need Data Split into two strings Like
String1 enter image description here

String2 enter image description here

We tried like this but We don't have luck so Please guide me

var split = string.split('\r\n');

Please help me

like image 441
Pavan Alapati Avatar asked Apr 10 '15 09:04

Pavan Alapati


People also ask

How do I split a string into multiple strings in R?

To split a string in R, use the strsplit() method. The strsplit() is a built-in R function that splits the string vector into sub-strings. The strsplit() method returns the list, where each list item resembles the item of input that has been split.

How do I split a string by next line?

To split a string on newlines, you can use the regular expression '\r?\ n|\r' which splits on all three '\r\n' , '\r' , and '\n' . A better solution is to use the linebreak matcher \R which matches with any Unicode linebreak sequence. You can also split a string on the system-dependent line separator string.

How do I split a string in delimiter in R?

Use str_split to Split String by Delimiter in R Alternatively, the str_split function can also be utilized to split string by delimiter. str_split is part of the stringr package. It almost works in the same way as strsplit does, except that str_split also takes regular expressions as the pattern.

How do you split a string into a carriage return?

newStr = splitlines( str ) splits str at newline characters and returns the result as the output array newStr . splitlines splits at actual newline characters, not at the literal \n . To split a string that contains \n , first use compose and then use splitlines .


1 Answers

try this:

var split = string.split(/\n/);
like image 89
Victor Lin Avatar answered Nov 14 '22 22:11

Victor Lin