Breaking News
Loading...
30/09/2013

Use Regex.Split Method to process string in C#

Tôi thường dùng hàm Regex.Split để xử lý chuỗi trong C# do yêu cầu công việc. Chỉ note lên đây để dễ tra cứu khi cần.
 
string input = @"07/14/2007";   
      string pattern = @"(-)|(/)";

      foreach (string result in Regex.Split(input, pattern)) 
      {
         Console.WriteLine("'{0}'", result);
      }

1 cách khác:
 
string[] arrEmail = emailList.Split(new char[] { ',', ';' }, StringSplitOptions.RemoveEmptyEntries);


Tham khảo: http://msdn.microsoft.com/en-us/library/8yttk7sy.aspx

0 comments:

Post a Comment

 
Toggle Footer