create a regular expression that finds the terms "net", "gross", and "super" in any order in csharp

You can use the following regular expression to match the terms "net", "gross", and "super" in any order:

main.cs
string pattern = @"^(?=.*\bnet\b)(?=.*\bgross\b)(?=.*\bsuper\b).*$";
69 chars
2 lines

This regular expression uses positive lookahead assertions to ensure that each of the three terms appears in the input string. The .* before and after the lookahead assertions matches any characters before or after the terms. The \b ensures that the terms are matched as whole words.

Here's an example of using this regular expression in C#:

main.cs
string input = "The super gross net income was $1000.";
string pattern = @"^(?=.*\bnet\b)(?=.*\bgross\b)(?=.*\bsuper\b).*$";
bool isMatch = Regex.IsMatch(input, pattern);
Console.WriteLine(isMatch);  // Outputs: True
217 chars
5 lines

gistlibby LogSnag