In my program, I read in a file using this statement:
string[] allLines = File.ReadAllLines(dataFile);
But I want to apply a Regex to the file as a whole (an example file is shown at the bottom) so I can eliminate certain stuff I'm not concerned with in the file. I can't use ReadAllText as I need to read it line by line for another purpose of the program (removing whitespace from each line).
Regex r = new Regex(@"CREATE TABLE [^\(]+\((.*)\) ON");
(thanks to chiccodoro for this code)
This is the Regex that I want to apply.
Is there any way to change the array back into one text file? Or any other solution to the problem?
Things that pop into my mind is replacing the 'stuff' that I'm not concerned with with string.Empty
.
example file
USE [Shelleys Other Database]
CREATE TABLE db.exmpcustomers(
f_name varchar(100) NULL,
l_name varchar(100) NULL,
date_of_birth date NULL,
house_number int NULL,
street_name varchar(100) NULL
) ON [PRIMARY]