Medicare Eligibility EDI Example Responses is what I'm trying to match.
I have a string that looks like this:
LN:SMITHbbbbbbbbFN:SAMANTHAbbBD:19400515PD:1BN:123456PN:9876543210GP:ABCDEFGHIJKLMNOID:123456789012345bbbbbPC:123PH:8005551212CD:123456PB:123ED:20060101TD:2070101LC:NFI:12345678FE:20070101FT:20080101I need a set of matches that look like this:
Key | Value ------------------- LN | SMITHbbbbbbbb FN | SAMANTHAbb BD | 19400515 ... etc
I've been dealing with this all day, and I can't seem to get an acceptable matching scenario. I'm about to program it procedurally with a for loop and finding indexes of colons if I can't figure something out.
I've tried using negative lookahead and I'm not getting anywhere. This is C#, and I'm using this tester (.Net) while I'm testing, along with The Regex Coach (non .Net).
I've tried using this:
([\w]{2})\:(?![\w]{2}\:)
But that only matches the keys and their colons, like "LN:", "FN:", etc.
If I use:
([\w]{2})\:(.+?)([\w]{2})\:
It consumes the next matching two character key and colon as well, leading to me only matching every other key/value pair.
Is there a way for me to match these using RegEx in .Net correctly, or am I stuck with a more procedural solution? Keep in mind, I can't assume that the keys will always be upper case letters. They could possibly include numbers, but they will always be two characters and then a colon.
Thanks in advance for any help I can get.