ধরা যাক আমাদের স্ট্রিং হল −
string str = "The Shape of Water got an Oscar Award!";
প্রতিটি শব্দের প্রথম অক্ষর −
প্রদর্শন করতে নিম্নলিখিত রেগুলার এক্সপ্রেশন ব্যবহার করুন@"\b[a-zA-Z]"
এখানে সম্পূর্ণ কোড −
উদাহরণ
using System;
using System.Text.RegularExpressions;
namespace RegExApplication {
public class Program {
private static void showMatch(string text, string expr) {
Console.WriteLine("The Expression: " + expr);
MatchCollection mc = Regex.Matches(text, expr);
foreach (Match m in mc) {
Console.WriteLine(m);
}
}
public static void Main(string[] args) {
string str = "The Shape of Water got an Oscar Award!";
Console.WriteLine("Display first letter of each word!");
showMatch(str, @"\b[a-zA-Z]");
}
}
} আউটপুট
Display first letter of each word! The Expression: \b[a-zA-Z] T S o W g a O A