const brandPath = path_arr[2]; // e.g lazacode-org const brandName = brandPath.replace(/-/g,' '); console.log(brandName); // will output lazacode org