I am voting +5 for OriginalGriff's elegant solution above ... and you should too :) ... but ... I was curious to know the pain of implementing this using 'Split' so here goes:
private List<string> method1;
private string method2;
private string method3;
private string stringForSplit = "<m>";
private void button1_Click(object sender, EventArgs e)
{
var result = textBox1.Text
.Split(stringForSplit.ToCharArray())
.Where(s => (!String.IsNullOrWhiteSpace(s)))
.ToList();
result = result.GetRange(1, result.Count - 2);
method1 = result;
method2 = result.Last();
method3 = result.First();
textBox2.Lines = result.ToArray();
}
Discussion:
1. would be interesting to compare performance of Split versus RegEx for this scenario.
2. to really compare the 'generalized usefulness' of this technique compared to RegEx would require skills beyond my knowledge of RegEx.