Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I cut a string after X characters?

How can I cut a string after a specific number of characters in JavaScript?

I then want to append the '…' Unicode character. How can I do this?

like image 504
Michael Unterthurner Avatar asked Aug 09 '13 12:08

Michael Unterthurner


People also ask

How do you split a string after a character?

To split a string at a specific character, you can use the split() method on the string and then pass that character as an argument to the split() method in JavaScript.

How do you put a string after a slash?

Use the . substring() method to get the access the string after last slash.

How do I cut the first letter of a string?

Method 1: Using slice() Method: The slice() method extracts the part of a string and returns the extracted part in a new string. If we want to remove the first character of a string then it can be done by specifying the start index from which the string needs to be extracted. We can also slice the last element.


1 Answers

Simply

  var trunc = "abcdef".substr(0, 3) + "\u2026";
like image 84
Alex K. Avatar answered Oct 21 '22 07:10

Alex K.