Forum Discussion
Hi @AleksandarAngelevski, thank you very much. that helped.
I am actually looking for docnames that doesn’t exist in filename array. so I removed ! from your expression;
$docname.filter((x,ind,arr) => $filename.indexOf(x) == -1)
$docid.filter((x,ind) => $filename.indexOf($docname[ind]) == -1)
$docext.filter((x,ind) => $filename.indexOf($docname[ind]) == -1)
but looks like my data is coming bit differently, the docname are coming with characters, how can I compare with out converting to string to replace these characters?
[
{
"filename": [
"Coupa_Supplier_SB_Tax_Cert_PO_4501923290",
"Coupa_Supplier_SB_Tax_Cert_PO_4501888888"
],
"id": 16755,
"docid": [
"FOL18 4 EXT48000000000761",
"FOL18 4 EXT48000000000760",
"FOL18 4 EXT48000000000759"
],
"docname": [
"Coupa_Supplier /SB_Tax_Cert PO #4501999999",
"Coupa_Supplier_SB_Tax_Cert_PO 4501923290",
"Coupa_Supplier_SB_Tax_Cert_PO_4501888888"
],
"docext": [
"pdf",
"pdf",
"pdf"
]
}
]
Also looks like my destination system accepts only _ so after match, need to replace spaces, #, / to _.
Thanks
Manohar
If you need to replace them for the target system, you can do that before the filtering using regex.
The following expression might not catch all of your scenarios but should be a good starting point:
$docname.map(x => x.replace(/(#|\/|\s){1,2}/g,'_'))
BR,
Aleksandar 🙂