I have this file which has control chars in it like decimal 29, 30. In note pad++ these come out to GS, RS respectively. In C# I’m doing a File.ReadAllLines… then for each line I need to split the entire line on these control chars.
Lets’ say I have a line as in:
1RSACCTGS2RS718GS3RS425…
The elements I would expect are 1, ACCT, 2, 718, 3, 425…
I mean I can put the line into a toCharArray then check each char if it is a control as in:
if (char.IsControl(c)) but I don’t think that’s too efficient. A regex would be nice I think but not sure how to write it. Any ideas?
Thanks,
David
Use
string.Splitmethod, and pass it an array of control characters on which you would like to split:Now
tokenscontains an array of substrings of the original line that were separated by the special characters. Multiple special characters in a row are ignored.