JamesNT
asked on
Regular Expressions in C#
I have the following string:
DMG*D8*19481101*M~NM1*PR*2 *EDS/MEDIC AID*****PI *DNC00~
I need to find certain matches of that string. Here is what I have tried:
string sPattern = @"DMG\*D8%~NM1\*PR\*2\*%PI \*DNC00~";
The issue is that, for example, the 19481101 could be a different number. I don't care about that, nor do I care about the EDS/MEDICAID. Those parts can change and it's fine. In my pattern above, the parts I don't care about are denoted by a % (I realize its not legal in C# I'm just using it for illustrative purposes). What I'm attempting to do is match up the parts I have that are literal and tell Regex that the parts denoted by % can by anything, I don't care, just ignore them. By the way, this is all inside a text file (I'm looking for one part out of possible thousands of characters).
Suggestions?
JamesNT
DMG*D8*19481101*M~NM1*PR*2
I need to find certain matches of that string. Here is what I have tried:
string sPattern = @"DMG\*D8%~NM1\*PR\*2\*%PI
The issue is that, for example, the 19481101 could be a different number. I don't care about that, nor do I care about the EDS/MEDICAID. Those parts can change and it's fine. In my pattern above, the parts I don't care about are denoted by a % (I realize its not legal in C# I'm just using it for illustrative purposes). What I'm attempting to do is match up the parts I have that are literal and tell Regex that the parts denoted by % can by anything, I don't care, just ignore them. By the way, this is all inside a text file (I'm looking for one part out of possible thousands of characters).
Suggestions?
JamesNT
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
JamesNT