It looks like for some reason, the regex that strips trailing spaces and commas, is also stripping off \r (carriage returns), but only for the barcodes that don't have trailing spaces..
Ohhh, it is that $ match. The $ is matching the \r, but if there are spaces or commas, it matches those and leaves the \r.
line = line.replace(/(.*?)($|\s.*|,.*)/,'$1');
Here is the barcode array before and after the regex.
I wonder of the original author of this was using files created in Linux, with no carriage returns. I just converted my file to unix EOL, and now it works fine as written. I think the code needs to handle both.
It looks like for some reason, the regex that strips trailing spaces and commas, is also stripping off \r (carriage returns), but only for the barcodes that don't have trailing spaces..
Ohhh, it is that $ match. The $ is matching the \r, but if there are spaces or commas, it matches those and leaves the \r.
line = line.replace( /(.*?)( $|\s.*| ,.*)/,' $1');
Here is the barcode array before and after the regex.
Pre import barcodes: ,\r", "\r", "33500012542726, \r", "35500004468045 ,\r", "\r", "33500012225165\r", "35500005727696 \r", "35500006028581\r", "35500004587208 \r", "35500003474093\r", … ]
Array(17) [ "35500004207930
Imported barcodes:
Array(12) [ "35500004207930\r", "33500012542726\r", "35500004468045\r", "33500012225165", "35500005727696\r", "35500006028581", "35500004587208\r", "35500003474093", "35500004587182\r", "35500006007197", … ]
app.js:300:13
I wonder of the original author of this was using files created in Linux, with no carriage returns. I just converted my file to unix EOL, and now it works fine as written. I think the code needs to handle both.
Josh