I have a string i want to split it so that I can extract the name from the particular string.
let str = "CN=John Mcclau - i0c00cu,OU=PET_Associates,OU=Users,OU=PET,DC=officecabs,DC=SAT-PET,Dt=com";
let splitstr= str.substr(3, str.indexOf(' -'))
console.log(splitstr)
Sample str2 = "PN=Coey PT - ljooys4,OU=PET_Associates,OU=Users,OU=PET,DC=officecabs,DC=SAT-PET,Dt=com";
I am doing this way but it displays the " - " too. How can i fix it?