Hope somebody can help me regarding regular expression.

I have a shortcode format "<!--myproductsku-->" in the string, I want to use regular expression to extract myproductsku. And if there is a match replace "<!--myproductsku-->" with "This is my myproductsku.".


Rey

Recommended Answers

All 3 Replies

Regex.Replace("<!--myproductsku-->","<!--\s+-->","")

try this

// Static method:
if (Regex.IsMatch(txtName.Text, @"<!--myproductsku-->"))
{
      string result = reg.Replace("<!--myproductsku-->" ,"This is my myproductsku.");
       Console.WriteLine("Replacement String: {0}", result);
}
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.