var split

Dear all ,
I use this

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.
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Kevin CrossChief Technology OfficerCommented:
Often what you have is carriage return, then line feed.

Open in new window

Therefore, make sure the character is indeed a newline versus a carriage return as well as not both.
ethar1Author Commented:
yes its  a new line
ethar1Author Commented:
even \r\n don't work
Your Guide to Achieving IT Business Success

The IT Service Excellence Tool Kit has best practices to keep your clients happy and business booming. Inside, you’ll find everything you need to increase client satisfaction and retention, become more competitive, and increase your overall success.

ethar1Author Commented:
btw, when I use

Open in new window

its work fine...
kaufmed   ( ⚆ _ ⚆ )Commented:
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:


Open in new window

Rainer JeschorCommented:
it works if you create a new regexp based on the input variable like:
function RunSplit() {
    var teststring = 'Hello\nWorld';
    var sep = new RegExp($('#mysplit').val());

Open in new window

See example here:


Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
In HTML it's <br>; otherwise, try to use vbCrlf instead of the text \n.
ethar1Author Commented:
none work,
its not html
@ Rainer Jescho, I have the data in text box
kaufmed   ( ⚆ _ ⚆ )Commented:
Can you attach a sample of the text as a file so that we can see what you are working with?
ethar1Author Commented:
ethar1Author Commented:
Rainer Jeschor, could you please explain why?
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.