The following code deletes double blank lines at the beginning, as well as double blank lines anywhere in the text field.
Dim myText as String = TextBox1.Text
myText = Regex.Replace(myText, "^(\r\n\r\n)(.*)", "$2")
myText = Regex.Replace(myTextt, "(.*\r\n)(\r\n\r\n)(.*)", "$1$3")
TextBox1.Text = myText
In the above example, it will delete lines 1 and 2, as well as lines 7 and 8.
source
share