Topic: Variable Delimiter Detection

ANSI X12 Algorithms

    Preconditions: Single byte character set, and data string starts with "ISA".

    Given the following partial string of data that begins an interchange:

ISA*e1*e2*e3*e4*e5*e6*e7*e8*e9*e10*e11*e12*e13*e14*e15*>~GS*e1*e2*etc...

    The algorithm will determine the element delimiter is the next character after the interchange control header segment id. Now that the element delimiter is known the algorithm will jump to the 16th element delimiter position. The sub element separator will be the next character and the segment delimiter will be the next character after the sub element separator.

    The algorithm will determine the element delimiter is the next character after the interchange control header segment id. Now that the element delimiter is known the algorithm will search for the functional group header segment id with the element delimiter. The segment delimiter will be the prior character and the sub element separator will be the prior character before the segment delimiter.

UN/EDIFACT Algorithms

    Preconditions: Single byte character set, and data string starts with "UNA" or "UNB".

    Given the following partial string of data that begins an interchange:

UNA:+.? 'UNB+e1+e2'UNG+e1+e2'

    If the service string advice segment is detected then the algorithm will determine the sub element separator is the first character after the service string advice segment id, the element delimiter is the second character, and the segment delimiter is the sixth character.

    The algorithm will determine the element delimiter is the next character after the interchange control header segment id. Now that the element delimiter is known the algorithm will search for the functional group header segment id with the element delimiter. If the functional group header segment id with the element delimiter cannot be found then the algorithm will search for the transaction set header segment id with the element delimiter. The segment delimiter will be the prior character from the start position of the search result. The sub element separator will be the first character not in the set of [' 0 '..' 9 ',' A '..' Z ',' a '..' z ',< element delimiter >, < segment delimiter >] going backwards through the string by character.