How to split a string stored in list<*> , then insert to same list using linq style or lambda ?

Total Post:149

Points:1043
 1881  View(s)
Ratings:
Rate this:

I have Writen o code using linq

var result=from m in driver_list select(m.Email,m.LisancePlate)

My code Output is like this

sample1@company.com;sample2@company.com----34 KZ 7898 sample3@company.com;sample2@company.com---- 34 TZK 6785

I want to a new output using my result like this sample1@company.com---34 KZ 7898 sample2@company.com---34 KZ 7898 sample3@company.com---34 TZK 6785 sample2@company.com---34 TZK 6785

  1. Post:24

    Points:168
    Re: How to split a string stored in list<*> , then insert to same list using linq style or lambda ?

    string input = "sample1@company.com;sample2@company.com----34 KZ 7898 sample3@company.com;sample2@company.com---- 34 TZK 6785";
    
    var result = string.Join(" ", Regex.Split(input, "\\s(?=\\S+@)")
                                 .Select(x=>{
                                    var s = x.Split(new string[] {";","----"}, StringSplitOptions.RemoveEmptyEntries);
                                    return string.Format("{0}---{2} {1}---{2}",s[0],s[1],s[2]);
                                 }).ToArray());//

      Modified On Mar-31-2018 04:51:18 AM

Answer