How to remove last 2 lines from a string

How to remove last 2 lines from a string

Hi,

Can you try the following?

System.Text.RegularExpressions.Regex.Replace(text,"\r?\n.*\r?\n.*$","")

Regards,

1 Like

@Sweety_Girl An alternate method using String Manipulations would be :

String[] strArray;
strArray = Split(str,Environment.NewLine)
newStr = String.Join(Environment.NewLine,strArray.Take(strArray.Count-2))

Where str is your String value

1 Like

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.