JSFiddle - React, Tailwind, and code Playground
by dshilkret
JavaScript
var itemPath = "https://dtecho365.sharepoint.com/sites/ServiceNowDev1/EnhancedUploadLib/DD 2875.pdf"
var filename = "DD 2875.pdf";
var sitesIndexPos = itemPath.indexOf("/sites/");
var filenameIndexPos = itemPath.indexOf(filename);
console.log(sitesIndexPos + " " + filenameIndexPos);
var path = "https://dtecho365.sharepoint.com/sites/ServiceNowDev1/EnhancedUploadLib/DD 2875.pdf";
var str = path;
var n = str.lastIndexOf('/');
var result = str.substring(n + 1);
console.log(result);