EDI
EDI copied to clipboard
BUG: element() method , if a element's value is NULL
EDI.js:37 var elements = this.string.match(/(\?.|[^\+])+/g)
var s = new EDI("PAC+1++CT'")
s.element(0) // results to "PAC" - RIGHT
s.element(1) // results to "1" - RIGHT
s.element(2) // results to "CT" - WRONG! it should result to ""
s.element(3) // results to "" - WRONG! it should result to "CT"
Thanks.
Hi Maslow,
Thanks for reporting this! Sorry for reacting so late.
Current implementation is:
"PAC+1++CT".match(/(\?.|[^\+])+/g)
(3) ["PAC", "1", "CT"]
I am not sure why I made this regex so complex to match on the content - which now seem to mismatch empty content - and not on the separator "+". Here is what would be correct for your case:
"PAC+1++CT".split(/\+/g)
(4) ["PAC", "1", "", "CT"]
Would you have a suggestion on how to implement this? Thanks,
Nabi