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

153
Views
How am i able to put new line after n amount of words (characters more specifically, then rounded to words) on javascript?

I was able to use .replace(/.{40}/g, '$&\n') to put a new line on every 40th character of a word from the input, but that cuts words in the middle. What is a wise choice in the situlation? Thanks!

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

0

I don't know the answer. That said, I'd hazard the following system might work:

  • see if the character 41 is equal to [a-zA-Z]
  • if it is indeed the middle of the word, insert a linebreak in the previous whitespace

Hope this might help!

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!