Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

152
Views
How to get text after the 9th occurrence of a character using javascript?

I got the following string: NPA-Woodburn,OR,Woodburn,OR,97071,Bensenville,IL,60106,150.00,0.00,cash/certified funds,,enclosed,operable,,,,,

I need to loop through some rows and sum the 9th text after ",", but I just can't get to it. I've seen many combinations of solutions, but none gets me there.

Thank you.

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

You can split the string by that character, remove all items in the array before the 9th item (with slice), then join the array back by the character.

const character = ",";

const str = "NPA-Woodburn,OR,Woodburn,OR,97071,Bensenville,IL,60106,150.00,0.00,cash/certified funds,,enclosed,operable,,,,,";

const res = str.split(character).slice(9).join(',')
console.log(res)

To isolate the 8th occurence, you can make the range in the slice call more specific:

const character = ",";

const str = "NPA-Woodburn,OR,Woodburn,OR,97071,Bensenville,IL,60106,150.00,0.00,cash/certified funds,,enclosed,operable,,,,,";

const res = str.split(character).slice(8,9)[0]
console.log(res)

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!