I have the following Regex that is being used to matching incoming packets:
public static class ProtobufConstants
{
public static Regex ContentTypeNameRegex => new Regex("application/protobuf; proto=(.*?)");
}
I also need to write outgoing packets strings in the same format, i.e. create strings similar to "application/protobuf; proto=mynamespace.class1" ideally by using the same regex definition new Regex("application/protobuf; proto=(.*?)");.
To keep this code in one place, is it possible to use this regex template and replace the (.*?) parameter with a string (as per above example i would like to substitute "mynamespace.class1").
I see there is a Regex.Replace(string input, string replacement) but given the above ContentTypeNameRegex already has the format defined I don't have an input per se, I just want to format - not sure what to put here, if anything.
Is it possible to use in this manner, or do i need to revert to string.Format?
public static Regex ContentTypeNameRegex(string protoPattern = ".*?")?