Mã:
using System;using System.Text.RegularExpressions; class ChuongTrinh{ static void Main() { string chuoi = "Mot, Hai, Ba, Trung Tam Dao Tao Cong Nghe Thong Tin"; Console.WriteLine("\""+chuoi+"\""); Console.WriteLine("Cat chuoi dua vao 1 ky tu hay 1 chuoi phan cach: "); Regex quytac = new Regex(", "); foreach (string str in quytac.Split(chuoi)) { Console.Write(str+"
"); } chuoi = "Mot Hai Ba "; Console.WriteLine("
\"" + chuoi + "\""); Console.WriteLine("Tim chuoi dua vao toan hoc:"); quytac = new Regex(@"(\S+)"); foreach (Match math in quytac.Matches(chuoi)) { Console.Write("Chuoi: "+math.ToString()+" co chieu dai la "+math.Length+" ky tu
"); } chuoi = "10:20:30 127.0.0.0 Dolphin.net 10:5:3 192.14.16.23 trong.net"; Console.WriteLine("
\"" + chuoi + "\""); Console.WriteLine("Phan chuoi thanh cac nhom: "); quytac = new Regex(@"(?<tg>(\d|\:)+)\s"+@"(?<ip>(\d|\.)+)\s" +@"(?<web>\S+)"); foreach (Match math in quytac.Matches(chuoi)) { Console.Write("Chuoi: " + math.Groups["tg"]+"
"); Console.Write("Chuoi: " + math.Groups["ip"] + "
"); Console.Write("Chuoi: " + math.Groups["web"] + "
"); } Console.ReadLine(); } }
View more random threads:
Pallet nhựa Lâm Đồng giải pháp hoàn hảo cho nhà kho Pallet nhựa Lâm Đồng là một giải pháp đa năng và hiệu quả trong việc vận chuyển và lưu trữ hàng hóa. Trong đó, pallet nhựa Lâm Đồng không chỉ đáp...
Pallet nhựa Lâm Đồng giải pháp...