I have an EDI file whose structure is given below. This file has multiple records, each record contains a header(e.g EDI.DD.00000000 01.20130809), then contents (i.e multiple paragraphs of text) and then footer (e.g End of Report/No EDI Activity). I have to read that entire file using regular expression using three groups.
I am using following regular expression to read the file.
(?<header>[A-Z]{3}.[A-Z]{2}.[0-9]{10}.[0-9]{8}) | (?<footer> \b(End\sof\sRep ort|No\sEDI\sAc tivity)\b) |
(?<content>(?<= \k<header>).*(? =\k<footer>))
That expression reads the "header" and "footer" in respective groups properly but didn't pick the contents between header and footer in "contents" group.
I have changed the font of header and footer in below file to help to understand the format. I am using asp.net 3.5 framework.
Thanks for your help in advance.
//------------------Start of EDI File---------------------//
EDI.DD.00000000 01.20130809
ORIGINATOR INFORMATION Company Name: UNITED HEALTHCAR Identification: 9024125001 Originating DFI: 002100002
RECEIVER INFORMATION Receiver Name: HEALTH & WELLNESS DFI Account Number: 000000000000000 1 Receiving DFI ID: 434343430 ID Number: Transaction Type: 22 Deposit
ORIGINATOR INFORMATION Company Name: BLUE CHOICE Identification: 9024125001
End of Report
EDI.DD.00065789 87.20130809
No EDI Activity
EDI.SV.00000005 55.20130809
ORIGINATOR INFORMATION Company Name: Univ of Florida Identification: A426004813 Originating DFI: 004200001
TRANSACTION INFORMATION
Entry Description: vndr pymnt Entry Class Code: CTX Service Class Code: ACH Entries Mixed
REMITTANCE ADVICE ACCOUNTS
RECEIVABLE OPEN ITEM REFERENCE
Seller's Invoice Number: 10016 Pmt Action Code: Amount Paid: $800.00 Amount of Invoice: Amount of Discount:
End of Report
//--------------------End of file------------------------//
I am using following regular expression to read the file.
(?<header>[A-Z]{3}.[A-Z]{2}.[0-9]{10}.[0-9]{8}) | (?<footer> \b(End\sof\sRep ort|No\sEDI\sAc tivity)\b) |
(?<content>(?<= \k<header>).*(? =\k<footer>))
That expression reads the "header" and "footer" in respective groups properly but didn't pick the contents between header and footer in "contents" group.
I have changed the font of header and footer in below file to help to understand the format. I am using asp.net 3.5 framework.
Thanks for your help in advance.
//------------------Start of EDI File---------------------//
EDI.DD.00000000 01.20130809
ORIGINATOR INFORMATION Company Name: UNITED HEALTHCAR Identification: 9024125001 Originating DFI: 002100002
RECEIVER INFORMATION Receiver Name: HEALTH & WELLNESS DFI Account Number: 000000000000000 1 Receiving DFI ID: 434343430 ID Number: Transaction Type: 22 Deposit
ORIGINATOR INFORMATION Company Name: BLUE CHOICE Identification: 9024125001
End of Report
EDI.DD.00065789 87.20130809
No EDI Activity
EDI.SV.00000005 55.20130809
ORIGINATOR INFORMATION Company Name: Univ of Florida Identification: A426004813 Originating DFI: 004200001
TRANSACTION INFORMATION
Entry Description: vndr pymnt Entry Class Code: CTX Service Class Code: ACH Entries Mixed
REMITTANCE ADVICE ACCOUNTS
RECEIVABLE OPEN ITEM REFERENCE
Seller's Invoice Number: 10016 Pmt Action Code: Amount Paid: $800.00 Amount of Invoice: Amount of Discount:
End of Report
//--------------------End of file------------------------//
Comment