एक स्ट्रिंग सेट करें:
string str = "Bit and Bat";
मान लीजिए आपको B और t के बीच जो भी आता है उसे A से बदलना है और पूरी स्ट्रिंग को कैपिटलाइज़ करना है। इसके लिए, Replace का उपयोग करें:
Regex.Replace(str, "B.t", "BAT");
आइए पूरा कोड देखें:
उदाहरण
using System; using System.Text.RegularExpressions; namespace Demo { class Program { static void Main(string[] args) { string str = "Bit and Bat"; Console.WriteLine(str); string res = Regex.Replace(str, "B.t", "BAT"); Console.WriteLine(res); } } }आउटपुट
Bit and Bat BAT and BAT