Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8919791
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T06:06:43+00:00 2026-06-15T06:06:43+00:00

I have a external resource (raw text file) like: 1. Title 1 Content 1

  • 0

I have a external resource (raw text file) like:

1. Title 1
Content 1
|
2. Title 2
Content 2
|
3. Title 3
Content 3

I load them in a web page via AJAX and want to use content.split(“\n|\n”) to extract its content into an array for my use. But it seems it’s not working.

What’s weird is that split(“\n|”) works, but neither do split(“|\n”) nor split(“\n|\n”) work.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T06:06:44+00:00Added an answer on June 15, 2026 at 6:06 am

    That’s not JavaScript related. That’s related to the operating system.

      var canonicalizeNewlines = function(str) {
          return str.replace(/(\r\n|\r|\n)/g, '\n');
      };
    

    Basically DOS(Windows), FreeBSD and Unix systems use different white characters to end a line. /r is for DOS ,/r/n is for FreeBSD based(Mac). This will enforce a single style for all your new lines, the Unix default style which is \n.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an external resource similar to https://www.googleapis.com/freebase/v1/text/en/bob_dylan which returns a JSON. I want
I have code that must poll an external resource periodically. Simplified, it looks like:
I have a web application using Kerberos to access an external resource useing ASP.NET
I have a button control which its template is stilyzed in an external resource
I would like to have external proofreaders to work directly inside my Drupal site.
I have several Java applications. All of them have external jar dependencies and also
I have an external setting file which has some nodes holiding attribute values of
I have an external Javascript file and i am trying to alert the value
I have an external file in php, outputed as json format I want the
I have a connection to an external resource that I need to make for

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.