एक स्ट्रिंग सेट करें -
string str = "Bit and Bat";
मान लीजिए कि आपको B और t के अंदर जो कुछ भी आता है उसे A से बदलने और पूरी स्ट्रिंग को कैपिटलाइज़ करने की आवश्यकता है। उसके लिए, बदलें का उपयोग करें -
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