JSFiddle - React, Tailwind, and code Playground

HTML

<body>
    <div id="test"></div>
    </body

JavaScript

var str = "file_path1\file_path2\file";
var rev = str.split("\");
                  
document.getElementById("test").innerHTML=rev[(rev.length)-1];