Regex ক্লাস (System.Text.RegularExpressions) ব্যবহার করে ওয়াইল্ডকার্ড প্যাটার্ন ম্যাচ করা যায়। * রেজেক্সে .* বা \S* দিয়ে রিপ্রেজেন্ট করা হয়।
উদাহরণ
using System;
using System.Text.RegularExpressions;
namespace Demo {
public class Program {
static void ShowMatch(string text, string pattern) {
MatchCollection mc = Regex.Matches(text, pattern);
foreach (Match m in mc) Console.WriteLine(m.Value);
}
public static void Main() {
string str = "toss cross tacos texas";
// 't' দিয়ে শুরু এবং 's' দিয়ে শেষ শব্দ
ShowMatch(str, @"\bt\S*s\b");
}
}
}
আউটপুট
toss tacos texas
প্যাটার্ন ব্যাখ্যা: \b = ওয়ার্ড বাউন্ডারি, t = 't' অক্ষর, \S* = নন-হোয়াইটস্পেস ০ বা অধিকবার, s = 's' অক্ষর, \b = ওয়ার্ড বাউন্ডারি।