From the course: C# and .NET Essential Training
Unlock the full course today
Join today to access over 23,200 courses taught by industry experts.
Replacing content - C# Tutorial
From the course: C# and .NET Essential Training
Replacing content
- [Instructor] All right, so now that we've seen in a previous video how to perform basic searching and matching with Regex patterns, let's try something a little more complex. In this example, we'll take a look at how to use Regex patterns not just to find content, but also replace it. So let's open up the code for the example here in my replacing folder. So I have the same text string as in the previous example. And once again I have an expression that matches capitalized words. So first let's use the replace function to replace capital words with some asterisks. All right, so here's what we're going to do. I'm going to write string result is equal to, and I'm going to call cap words and on the cap words Regex I'm going to call the replace function, and I'm going to replace the content in teststr1 with three asterisks. So basically, each one of these capitalized words should be replaced by three asterisk characters.…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.