Horje
Js last word in a string Code Example
javascript get last word in string
// strips all punctuation and returns the last word of a string
// hyphens (-) aren't stripped, add the hyphen to the regex to strip it as well
function lastWord(words) {
    let n = words.replace(/[\[\]?.,\/#!$%\^&\*;:{}=\\|_~()]/g, "").split(" ");
    return n[n.length - 1];
}
Js last word in a string
String test =  "This is a sentence";
String lastWord = test.substring(test.lastIndexOf(" ")+1);




Javascript

Related
javascript if null use other value Code Example javascript if null use other value Code Example
kitten ui input height multiline Code Example kitten ui input height multiline Code Example
cache management in angular 7 Code Example cache management in angular 7 Code Example
angular dropdown selected value Code Example angular dropdown selected value Code Example
Opposite number js Code Example Opposite number js Code Example

Type:
Code Example
Category:
Coding
Sub Category:
Code Example
Uploaded by:
Admin
Views:
8