Permalink
Cannot retrieve contributors at this time
Fetching contributors…
| // <Snippet6> | |
| using System; | |
| using System.Text.RegularExpressions; | |
| public class Example | |
| { | |
| public static void Main() | |
| { | |
| string pattern = @"\b\w+(?=\sis\b)"; | |
| string[] inputs = { "The dog is a Malamute.", | |
| "The island has beautiful birds.", | |
| "The pitch missed home plate.", | |
| "Sunday is a weekend day." }; | |
| foreach (string input in inputs) | |
| { | |
| Match match = Regex.Match(input, pattern); | |
| if (match.Success) | |
| Console.WriteLine("'{0}' precedes 'is'.", match.Value); | |
| else | |
| Console.WriteLine("'{0}' does not match the pattern.", input); | |
| } | |
| } | |
| } | |
| // The example displays the following output: | |
| // 'dog' precedes 'is'. | |
| // 'The island has beautiful birds.' does not match the pattern. | |
| // 'The pitch missed home plate.' does not match the pattern. | |
| // 'Sunday' precedes 'is'. | |
| // </Snippet6> |