Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>The X12 protocol standard allows the specification of element and component separators in the header, so anything that hard-codes the "|" and ">" characters could eventually break. Since the standard mandates that the characters used as separators (and segment terminators, e.g., "~") cannot appear within the data (there is no escape sequence to allow them to be embedded), parsing the syntax is very simple. Maybe you're already doing something similar to this, but for readability...</p> <pre><code>// The original segment string (without segment terminator): string segment = "PLB|1902841224|20100228|49&gt;KC15X078001104|.08"; // Parse the segment into elements, then the fourth element // into components (bounds checking is omitted for brevity): var elements = segment.Split('|'); var components = elements[3].Split('&gt;'); // If the first component is the bad value, replace it with // the correct value (again, not checking bounds): if (components[0] == "49") components[0] = "CS"; // Reassemble the segment by joining the components into // the fourth element, then the elements back into the // segment string: elements[3] = string.Join("&gt;", components); segment = string.Join("|", elements); </code></pre> <p>Obviously more verbose than a single regular expression but parsing X12 files is as easy as splitting strings on a single character. Except for the fixed length header (which defines the delimiters), an entire transaction set can be parsed with Split:</p> <pre><code>// Starting with a string that contains the entire 835 transaction set: var segments = transactionSet.Split('~'); var segmentElements = segments.Select(s =&gt; s.Split('|')).ToArray(); // segmentElements contains an array of element arrays, // each composite element can be split further into components as shown earlier </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload