I am using javascript and indexof to extract metadata values from one set and map them to values in another. This is so the values are available as search filters in an asset management platform. The source metadata is stored in Keywords in Adobe PDF files. They are comma separated values e.g.
Carton (Inc Sleeve),Joe Bloggs,Chilled,Pre-Packed,AB – Mid Tier,P080D41_V1,232×356,18022,Master,39L
My script maps the above against the 10 destination values with no issues. However, there are some instances where array values contain commas:
Flow Wrap,Joe Bloggs,Core Grocery,Rice,Pasta,Foreign Food,Mid-Tier 2023,NA,475×240,19183,Master,1203
In the above keywords, Rice,Pasta,Foreign Food should be mapped to one target value, but my script splits by comma and adds them as “Rice”,”Pasta”,”Foreign Food” and thus breaks the mapping.
I know the keywords that contain extra commas, so I need a way of locating them in the array and mapping them as a single value to the correct target value, without breaking the sequence of the mapping.
I have tried analysing the array for matches against the exception values, but I think because I’m then splitting it via var keywords = keywordsValue.split(“,”) they are not recognised.
Any advice appreciated!
DJH is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
0