Hi @lesponce ,
Agree with Bruce, Regex.Replace method is a good choice. You could refer the following code:
//Test data
var orderlist = new List<Order>()
{
new Order() {Id=1, Address="48 Street", Account=12},
new Order() {Id=2, Address="48 Street", Account=0},
new Order() {Id=3, Address="48th Street", Account=11},
new Order() {Id=4, Address="48 Street", Account=0},
new Order() {Id=5, Address="51th Street", Account=15},
};
//var orderresult = orderlist.RemoveAll(c => c.Account == 0);
var orderresult2 = orderlist.Where(c => c.Account != 0) //filter data and remove the Account is 0
.Select(c => new Order() {
Id = c.Id,
Address = Regex.Replace(c.Address, @"(\w+)(\d+)(th)(\s\w+)", "$1$2$4", RegexOptions.IgnoreCase),
Account = c.Account
}).ToList();
The result like this:
If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.
Best regards,
Dillion