2017-06-02 74 views

回答

0

使用以下正則表達式:

.*xxx\r\n.*xxx$ 

這會查找兩行以xxx結尾的行,並用\ r \ n(回車,換行)分隔。

這裏是工作示例的鏈接:.Net Fiddle

using System; 

public class Program 
{ 
    public static void Main() 
    { 
     var text = "adsfasdf asdfasd\r\nabcd abcdef xxx\r\nabcd abcdef xxx"; 
     System.Text.RegularExpressions.Regex regex = new System.Text.RegularExpressions.Regex(".*xxx\r\n.*xxx$"); 

     var matches = regex.Matches(text); 
     Console.WriteLine(matches[0].ToString()); 
    } 
} 
相關問題