EDI icon indicating copy to clipboard operation
EDI copied to clipboard

BUG: element() method , if a element's value is NULL

Open maslow opened this issue 8 years ago • 1 comments

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.

maslow avatar Feb 08 '17 08:02 maslow

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

nabudaldah avatar Sep 01 '17 12:09 nabudaldah