2010-09-03 50 views
0

我需要使用正则表达式如下数据改变我如何选择xx-xxx-xx-x格式的某个id?

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) 

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

我能做到这一点的LINQ?

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)" 

但我需要"ZL-531-01-1"

+4

您有询问** 236个问题**。我认为这足以知道如何正确格式化它们。请查看[Markdown编辑帮助](http://stackoverflow.com/editing-help),以及我对您问题的编辑。这实际上可能为您节省很多时间。 – 2010-09-03 06:34:16

+1

也许你也可以打扰接受和投票一些更多的答案... – 2010-09-03 06:38:44

+0

我认为,stackoverflow不好,我尝试写代码我的代码看起来不好。有些编辑得到了:[code] [/ code]我认为它很好! – Penguen 2010-09-03 06:45:36

回答

0

为什么不使用extension Method里面的linq重新格式化您的字符串使用正则表达式。

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