I have a long, one line text file in EDI format, and I need to find a way to read and store only a certain part of the file. Throughout the file, there are several instances of "[UNWANTED TEXT]CLM*[NUMBER]*[UNWANTED TEXT]", and I need to be able to grab that [NUMBER] portion, and store it+display it somewhere. I've been able to use Streamreader to read the entire file and display it, but I'm at a loss how to narrow it down to just the parts that I want. Any suggestions?
I'm working in VB.NET now, but I'd be willing to move to another language if it offers an easier way to do this.
Thanks for any help offered.
You can identify the pattern with Regular Expression and find your desired value through the
Regex
andMatch
classes ofSystem.Text.RegularExpressions
. Something like this should get you started:In this case, you'd have to load your EDI string into yourString. You can see how the regex I've put here functions by using something like Regex101
This is assuming that your string will only have one match of this pattern.