2015-10-14 62 views
-2

從大文本抽取子,我想只提取各子之間'郵件ADRESS '之間的文本..我怎麼會用記事本++或C#

如何只導入電子郵件地址記事本++宏或C# ?

Sample.txt;

(8428, 'John Doe的', '[email protected]','05 .Sep.2015 - 19時09分14' 秒,'12 .222.100.100' , 'sABqBpMRYh', '1', 0),

(8429,'Chris down','[email protected]','05 .Sep.2015- 19:10:03','11.214.100.100','z0gWsvcOMO','1 ',1),

請幫助我。

Regards

+3

請同時提供示例輸入 –

+0

在逗號周圍使用String Split方法可能會更好。 input.Split(new char [] {','}) – jdweng

回答

0

這很不清楚你的輸入數據是什麼樣子/你的輸出應該是什麼樣子。此外,沒有看到你已經開始的任何代碼,我不知道從哪裏開始爲你提供解決方案,但是也許這樣做會有所幫助。

List<string> lines = File.ReadAllLines(inputFile).ToList<string>(); 
List<string> data = new List<string>(); 
List<int> allIndices = lines.Select((s, i) => new { Str = s, Index = i }) 
    .Where(x => x.Str.Contains("'")) 
    .Select(x => x.Index).ToList<int>(); 

for (int j = 0; j < allIndices.Count() - 1; j++) 
    data.AddRange(lines.GetRange(allIndices[j], (allIndices[j + 1] - allIndices[j]))); 
  • lines將包含從文件
  • data是將被添加到
  • allIndices就是一個'發生於每個位置的列表空列表中的所有數據。

allIndicesfor循環迭代讓所有從lines內容在每個',並補充說之間data

你用data做什麼之後,這取決於你。

+0

你好,我有mailaddress.txt ...有子字符串「[email protected]」我們可以有嗎?過濾電子郵件? – fast