How can I take away textual content(e.g [“88664734”,“88639280”,“88676217”]) from a strReviewers string which comprises record of Reviewers separated by semicolon after which be part of the entire string once more both utilizing JavaScript or jQuery?
I get a dynamic string(strReviewers) which comprises a number of person data separated by comma:
I must take away entire person report if I go an array of ids. e.g [“88664734”,“88639280”,“88676217”]
var strReviewers = "88664734*,*Andrew Farmer*,*19042*,**,*,19013,19017,19042,19043,19051,*;*88639280*,*Sally Hopewell*,*19042*,**,*,19013,19017,19042,19043,*;*88686221*,*Jonathan Rees*,*19042*,**,*,19013,19017,19042,19043,19060,*;*88676217*,*James Wason*,*19042*,**,*,19013,19017,19042,19043,*;*";
strReviewers comprises person data separated by semicolon and every person report is separated by ,.
Every report comprises 1 person which is within the form of userid then following by identify then following by roleid then following by txtSpeciality following by then rolelist.
sort or paste code right here
/*
88664734*,*Andrew Farmer*,*19042*,**,*,19013,19017,19042,19043,19051,*;
*88639280*,*Sally Hopewell*,*19042*,**,*,19013,19017,19042,19043,*;
*88686221*,*Jonathan Rees*,*19042*,**,*,19013,19017,19042,19043,19060,*;
*88676217*,*James Wason*,*19042*,**,*,19013,19017,19042,19043,*;
*/
I've finished it utilizing the next code however questioning this may be achieved another simpler manner?
perform removeReviewerByID(ids = [])
return strReviewers
.cut up(";")
.map(merchandise => merchandise.cut up("*,*"))
.filter(merchandise => merchandise[0] !== "*")
.map(merchandise => (
userid:merchandise[0],
identify:merchandise[1],
roleid:merchandise[2],
txtSpeciality:merchandise[3],
rolelist:merchandise[4]
))
.filter(merchandise => (!ids.consists of(merchandise["userid"]) && !ids.consists of(merchandise["userid"].substitute(/*/g, ''))))
.map(merchandise => (
report: merchandise["userid"].concat("*,*").concat(merchandise["name"]).concat("*,*").concat(merchandise["roleid"]).concat("*,*").concat(merchandise["txtSpeciality"]).concat("*,*").concat(merchandise["rolelist"]).concat(";")
))
.cut back((accumulator, merchandise) =>
return accumulator.concat(merchandise["record"]);
, "")
console.log(removeReviewerByID(["88664734","88639280","88676217"]));