আমাদের স্ট্রিং হল −
string str = " My make ";
"make"
সাবস্ট্রিং খুঁজে পেতে নিম্নলিখিত রেগুলার এক্সপ্রেশন ব্যবহার করুন@"\bmake\b"
এখানে সম্পূর্ণ কোড −
উদাহরণ
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("Found:" + m);
}
}
public static void Main(string[] args) {
string str = "My make";
Console.WriteLine("Matching words start with 'm' and ends with 'e':");
showMatch(str, @"\bmake\b");
}
}
}
আউটপুট
Matching words start with 'm' and ends with 'e': The Expression: \bmake\b Found:make