Answers for "replace long string js"

2

cut text if too long javascript

if(snippet.length > 1024) {
text = snippet.substring(0, 1024)//cuts to 1024
last = text.lastIndexOf(" ")//gets last space (to avoid cutting the middle of a word)
text = text.substring(0, last)//cuts from last space (to avoid cutting the middle of a word)
text = text + ` (...)`//adds (...) at the end to show that it's cut
}
Posted by: Guest on July-26-2020
6

str replace javascript all

str.replace(/abc/g, '');
Posted by: Guest on May-16-2020

Code answers related to "Javascript"

Browse Popular Code Answers by Language