2010-10-03 61 views
0

我有一個文本文件,其中包含我的舊通訊錄中的大量電子郵件地址。我需要從中解脫出來。每封電子郵件阿迪是preceeded與c#正則表達式字符串,任何人都知道如何?

ip: 

\ 

例如結束

blablablaip:[email protected]\ 

是最大長度爲25個字符(不知道是否是有區別的地址所需的正則表達式是一個noob),有時在地址中間會出現換行符,即電子郵件地址在行尾和新行開始之間分開。

你們中的任何一位正則表達式向我提供任何幫助嗎?

在此先感謝

回答

1

你可以試試這個正則表達式:

/ip:(.{0,25}?)\/ 

它的工作原理是這樣的:

/   <- The delimiter of your regex 
    ip:  <- Matches the "ip:" part 
    (   <- Open a capture group 
     .   <- Matches any character 
     {0,25} <- Last part repeated between 0 and 25 times 
     ?   <- Ungreedy modifier, to capture less elements possible (in the 0, 25 limit) 
    )   <- End of the capture group 
    \   <- The "\" part 
/  <- End of the regex 

在C#中你不需要分隔符在你的正則表達式,所以你可以使用這個:

@"ip:(.{0,25}?)\\" //Don't forget to escape the \ 

資源:你正在尋找

+0

非常感謝我明白你說的話:) – brux 2010-10-03 22:33:49

0

正則表達式是

ip:(.*?)\\ 
0

您可能要剝離換行符,只是爲了簡單起見。

之後:

String regex = @"ip:(?'email'(.*)@(.*\.*))\\"; 

沒有長度的限制或字符限制,但它會匹配電子郵件的[email protected]部分,並把它的電子郵件小組。

相關問題