Link to home
Start Free TrialLog in
Avatar of ethar turky
ethar turkyFlag for Saudi Arabia

asked on

var split

Dear all ,
I use this
.split(lineSeperator);

Open in new window

to split based on passed variable from user input, its work fine , but when user use '\n'
for new line its not working as expected.
Avatar of Kevin Cross
Kevin Cross
Flag of United States of America image

Often what you have is carriage return, then line feed.
\r\n

Open in new window


Therefore, make sure the character is indeed a newline versus a carriage return as well as not both.
Avatar of ethar turky

ASKER

yes its  a new line
even \r\n don't work
btw, when I use
.split('\n');

Open in new window


its work fine...
I think this is why your previous question showed the optional carriage return ( \r? ). The standard line terminator under Windows is carriage-return/line-feed ( \r\n ). Not everyone follows this, though. Sometimes you have to make either optional in order to match against target data. In your case, I think you are looking for the optional carriage return, so I would modify your example to:

.split('\r?\n');

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of Rainer Jeschor
Rainer Jeschor
Flag of Germany image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
In HTML it's <br>; otherwise, try to use vbCrlf instead of the text \n.
none work,
its not html
@ Rainer Jescho, I have the data in text box
Can you attach a sample of the text as a file so that we can see what you are working with?
Rainer Jeschor, could you please explain why?