---
title: "How to split a string stored in list&lt;*&gt; , then insert to same list using linq style or lambda ?"  
description: "How to split a string stored in list&lt;*&gt; , then insert to same list using linq style or lambda ?"  
author: "Royce Roy"  
published: 2013-10-05  
updated: 2013-10-05  
canonical: https://www.mindstick.com/forum/1587/how-to-split-a-string-stored-in-list-lt-gt-then-insert-to-same-list-using-linq-style-or-lambda  
category: "asp.net"  
tags: ["asp.net"]  
reading_time: 1 minute  

---

# How to split a string stored in list&lt;*&gt; , then insert to same list using linq style or lambda ?

I have Writen o [code](https://yourviews.mindstick.com/view/85458/alan-turing-the-mastermind-behind-cracking-the-enigma-code-during-world-war-ii) using [linq](https://www.mindstick.com/articles/12007/language-integrated-query-linq-queries)

[var](https://www.mindstick.com/forum/33920/what-is-different-var-and-dynamic-types-in-c-sharp) [result](https://www.mindstick.com/blog/12011/advantages-of-getting-result-oriented-seo-from-an-agency)=from m in driver_list [select](https://www.mindstick.com/forum/160534/orderby-then-select-vs-select-then-orderby-performance)(m.Email,m.LisancePlate)

My code [Output](https://www.mindstick.com/interview/34427/explain-the-output-in-angular) 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

## Replies

### Reply by Dag Hammarskjold

```
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());//
```


---

Original Source: https://www.mindstick.com/forum/1587/how-to-split-a-string-stored-in-list-lt-gt-then-insert-to-same-list-using-linq-style-or-lambda

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
