New dad, so my eyes are tired and I'm trying to figure out why this code:
var regex = new Regex(@"(https:)?\/");
Console.WriteLine (regex.Replace("https://foo.com", ""));
Emits:
foo.com
I only have the one forward slash, so why are both being captured in the group for the replacement?
Regex.Replace:
In a specified input string, replaces all strings that match a regular expression pattern with a specified replacement string.
Every single / matches the regular expression pattern @"(https:)?\/". If you try e.g. "https://foo/./com/", all /s would be removed.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With