How do I trim a line after a long word?

  • 0
    There are paragraphs with text on the page. How to cut the text after a long word, and limit the word itself by the number of characters?
    I created an array of strings, then converted these strings into words, checked if the number of characters in a word is more than 19 - cut them off.
    I don't understand how to cut off the words that come after a long word.
    Here's what happened so far: Codepen
    JavaScript Penelope Kerr, Apr 1, 2019

  • 2 Answers
  • 0
    str.replace (/ (? & lt; = \ S {19,}). + /, '...')
    Chloe Yang

  • 0
    You have an array of words. Find the index of the long slice and use https: // developer. mozilla.org/uk/docs/Web/JavaScri ... to trim the word array.
    Declan Elliott

Your Answer
To place the code, please use CodePen or similar tool. Thanks you!