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

  • SEARCH
  • Home
  • 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 7581143
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T18:07:44+00:00 2026-05-30T18:07:44+00:00

I got 2 questions: My function looks like that function count() { var value

  • 0

I got 2 questions:

  • My function looks like that

    function count() {
    var value = ids.val();
    return (value == '') ? 0 : value.replace(/\s,?|,$/g, '').split(/\r\n|\r|\n/).length;
    }

What I wanna do is, to skip whitespaces and count all new lines
For ex:

85
96
75
<whitespace>
76

count() must return 4 not 5. How can I modify my function?

  • How to convert line break seperated words/numbers to comma seperated content?

For ex:

85
96
75<whitespace>
<whitespace>
76

I want to trim all whitespaces and convert whole content into something like that 85,96,75,76. How can I do it ?

  • 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-05-30T18:07:45+00:00Added an answer on May 30, 2026 at 6:07 pm

    The easiest way would be .filter($.trim).map($.trim), which first removes any whitespace entries, and then cleans the remaining entries by removing surrounding spaces: http://jsfiddle.net/BtLzf/1/.

    var vals = ids.val()
                 .split(/\r\n|\r|\n/)
                 .filter($.trim)
                 .map($.trim);
    
    vals.length; // 4
    vals.join(); // 85,96,75,76
    

    .filter/.map are ES5 which means you’ll need a shim for older browsers.

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

Sidebar

Related Questions

I've got a problem to solve in Jython. The function I've got looks like
I've got an XML file that contains a list of questions. I'd like to
I've got a trait that looks like this (some further information can be found
Playing with Erlang, I've got a process-looping function like: process_loop(...A long list of parameters
My database tables 1 row looks like that I'm storing all variables that used
I have a table with a row that looks like this: ( 20091231 48498429,
I've got an application that generates data for reports that look like: age <
Looks like the question got deleted when I was pasting code. I have included
i got a question when create a javascript object, when one function invoking another
vb.net windows forms question. I've got 3 forms that have exactly the same functions,

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.