I'm trying to replace parts of a generated code file:
public System.Nullable<int> SomeInt { get; set; }
public System.Nullable<bool> SomeBool { get; set; }
public System.Nullable<bool> SomeOtherBool { get; set; }
What I'm trying to get is this:
public int? SomeInt { get; set; }
public bool? SomeBool { get; set; }
public bool? SomeOtherBool { get; set; }
I know the code is equivalent, with the latter being just syntactic sugar. But I want to do it anyway cause it's more readable.
The regex patterns are easy enough to write,
System\.Nullable<.*>
for the whole thing, and something like
(?<=System\.Nullable<).*(?=>)
to get just the primitive type inside. But I can't for the life of me figure out how to use C#'s Regex API to implement the replacement correctly.
Regex.Replace()?