How to invert a regular expression?
How can I invert a regular expression?

    string InvertRegex(string r)
    {
      // ???
    }
    
    private static void Main()
    {
      // Just an example.
      string re = @"\b(?<word>\w+)\s+(\k<word>)\b";
    
      re = InvertRegex(string re);
    
      Regex regex = new Regex(re);
    
      // ...
    
      return;
    }


How to invert a regular expression?
===

How can I invert a regular expression?

    string InvertRegex(string r)
    {
      // ???
    }
    
    private static void Main()
    {
      // Just an example.
      string re = @"\b(?<word>\w+)\s+(\k<word>)\b";
    
      re = InvertRegex(string re);
    
      Regex regex = new Regex(re);
    
      // ...
    
      return;
    }

