How do I trim a line after a long word?
-
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: CodepenJavaScript Penelope Kerr, Apr 1, 2019 -
str.replace (/ (? & lt; = \ S {19,}). + /, '...')
Chloe Yang -
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
2 Answers
Your Answer
To place the code, please use CodePen or similar tool. Thanks you!