JSFiddle - React, Tailwind, and code Playground

JavaScript

var str = "Smith, John - PPP";

var res = str.split(",");

console.log(res[1].substr(1,4) + res[0]); // John Smith