Problem:

Cannot find a consistent way to replace a random string between quotes with a specific string I want. Any help would be greatly appreciated.

Example:

String str1 = "test=\"-1\"";

should become

String str2 = "test=\"31\"";

but also work for

String str3 = "test=\"foobar\"";

basically I want to turn this

String str4 = "test=\"antyhingCanGoHere\"";

into this

String str4 = "test=\"31\"";

Have tried:

Case insensitive Regex without using RegexOptions enumeration

How do you do case-insensitive string replacement using regular expressions?

Replace any character in between AnyText: and <usernameredacted@example.com> with an empty string using Regex?

Replace string in between occurrences

Replace a String between two Strings

Current code:

    Regex RemoveName = new Regex("(?VARIABLE=\").*(?=\")", RegexOptions.IgnoreCase);
    String convertSeccons = RemoveName.Replace(ruleFixed, "31");

Returns error:

System.ArgumentException was caught
  Message=parsing "(?VARIABLE=").*(?=")" - Unrecognized grouping construct.
  Source=System
Edit
Report