Permalink
Cannot retrieve contributors at this time
Fetching contributors…
| // <Snippet2> | |
| using System; | |
| using System.Text.RegularExpressions; | |
| public class Example | |
| { | |
| public static void Main() | |
| { | |
| string pattern = "(Mr\\.? |Mrs\\.? |Miss |Ms\\.? )"; | |
| string[] names = { "Mr. Henry Hunt", "Ms. Sara Samuels", | |
| "Abraham Adams", "Ms. Nicole Norris" }; | |
| foreach (string name in names) | |
| Console.WriteLine(Regex.Replace(name, pattern, String.Empty)); | |
| } | |
| } | |
| // The example displays the following output: | |
| // Henry Hunt | |
| // Sara Samuels | |
| // Abraham Adams | |
| // Nicole Norris | |
| // </Snippet2> |