हमारा तार है -
string str = " My 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