I have a string it contains project name and project ID.
var projectName= "BMW-ASSET-Management- 1133978889"
From above code i need to remove last - symbol.
I need var projectName="BMW-ASSET-Management"; var projectId="1133978889";
I tried to get projectId like
var projectId= projectName.slice(0,-13);
But not working this.
Can anyone please help me.
CodePudding user response:
use
x.split(/-\s/)
It will split into two parts as you expected
x = "BMW-ASSET-Management- 1133978889"
let [projectName, projectId] = x.split(/-\s/)