Remove Integer at end of string in C#

Last Reply 2 months ago By dharmendr

Posted 2 months ago

Dear All, 

I have multiple lines like below, in which the number changes in each line:

string Line1=No Exceptions Noted Page 30

string Line2=No Exceptions Noted Page 31

I was able to remove the word Page, but also I want to remove the number at the end of each line. How can I do this with below code? Or any suggestions?

string[] data = Line1.Split(new string[] { "Page" }, StringSplitOptions.None);



You are viewing reply posted by: dharmendr 2 months ago.
Posted 2 months ago

Refer below code.

string Line1 = "No Exceptions Noted Page 30";
Response.Write(Line1.Split(new string[] { "Page" }, StringSplitOptions.None)[0]);