JSFiddle - React, Tailwind, and code Playground

by Shef

HTML

<div>This is a test string with the last word</div>

CSS

span{
    color:red;
    font-weight: bold;
}

JavaScript

$div = $('div');

$div.html($div.text().replace(/(\w+?)$/, '<span>$1</span>'));