'How to negate whole regex [closed]

I have a pattern (pattern) and I want to exclude this characters in string 'test' and find all holes in this expression. Like test, but this characters will be random For the string 'test' I expect 'test' which is not matched by pattern ()



Solution 1:[1]

You could use Regex#Match here:

Regex regex = new Regex(@"(XZ|RP(?!ROD)|R|DP(?!ROD)|D|ST[\d]?|WO)");
Match match = regex.Match("testRPRODRRPWO");

if (!match.Success)
{
    Console.WriteLine("input does not contain pattern");
}

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Tim Biegeleisen