Regex.Split accepts a string, not an array of strings.
I would recommend calling Regex.Split for each content item individually, and then iterate over the results of this call. That would mean nested for loops.
string[] contents = File.ReadAllLines(filename); foreach (string line in contents) { string[] splitlines = Regex.Split(line); foreach (string splitline in splitlines) { string prefix = Regex.Match(splitline, @"(\S+)(\d+)").Groups[0].Value; File.AppendAllText(workingdirform2 + "configuration.txt", prefix+"\r\n"); } }
This, of course, is not the most effective way to do this.
A more efficient way would be to split into a regular expression. I think this works:
string splitlines = Regex.Split(File.ReadAllText(filename), "$|\\|");
Aaron source share