views:

67

answers:

1

I need to change below data

A320-ZL-522-01-1(2)
A320-ZL-531-01-1(1)
A320-ZL-531-01-1(2)
A320-ZL-531-01-1(1)
A320-ZL-531-01-1(2)

to

ZL-522-01-1
ZL-531-01-1
ZL-531-01-1
ZL-531-01-1
ZL-531-01-1

Can I do it with LINQ using RegEx?

public class MatchCTallyToCross
{
    public List<string> Get(string CustomerNumber)
    {
        IEngManager engManager = new EngManager();
        EngCustomerMyCross engCustomerMyCross = new EngCustomerMyCross();
        engManager.Load(engCustomerMyCross);
        return engCustomerMyCross.myEngCustomerCross.
            Where(c => c.ENG_CUSTOMERMYCROSS_CUSTOMER_NUMBER == CustomerNumber).
            Select(c => c.ENG_CUSTOMERMYCROSS_MYTECHNIC_TASK_NO).ToList();
    }
}

c => c.ENG_CUSTOMERMYCROSS_MYTECHNIC_TASK_NO result is equal to "A320-ZL-531-01-1(2)"

But i need "ZL-531-01-1".

A: 

Why dont you use an extension Method inside linq to reformat your string using regex.

c.ENG_CUSTOMERMYCROSS_MYTECHNIC_TASK_NO.ToNewDateFormat()//calling the extension method
Aneef