private void bTestExpression_Click(object sender, EventArgs e) { this.dataGridView1.Rows.Clear(); this.dataGridView1.Columns.Clear(); try { string[] ignore = tIgnore.Text.Split(' '); RegExReaderData rx = new RegExReaderData(this.tRegex.Text, ignore); using (MemoryStream ms = new MemoryStream(Encoding.ASCII.GetBytes(this.rtExample.Text))) { using (StreamReader sr = new StreamReader(ms)) { List <string> names = rx.GetNextStrings(sr); foreach (string s in names) { this.dataGridView1.Columns.Add(s.Replace(' ', '_'), s.Replace(' ', '_')); } List <double> vals; while ((vals = rx.GetNextDouble(sr)) != null) { object[] ob = new object[vals.Count]; for (int i = 0; i < ob.Length; i++) { ob[i] = (object)vals[i]; } this.dataGridView1.Rows.Add(ob); } } } } catch (Exception ex) { MessageBox.Show(ex.Message, "Error in regular expression", MessageBoxButtons.OK, MessageBoxIcon.Error); } }