Tag Archives: pattern replace

Replace text matching a pattern in C#

This example uses the following code to replace text matching a pattern within a string. // Make the replacements. private void btnGo_Click(object sender, EventArgs e) { Regex reg_exp = new Regex(txtPattern.Text); lblResult.Text = reg_exp.Replace( txtTestString.Text, txtReplacementPattern.Text); } This code creates … Continue reading

Posted in regular expressions, strings | Tagged , , , , , , , , , , , | Leave a comment