Is there a regex pattern that can remove .zip.ytu
from the string below?
werfds_tyer.abc.zip.ytu_20111223170226_20111222.20111222
Just use String.Replace()
String.Replace(".zip.ytu", "");
You don't need regex for exact matches.
Here is an answer using regex as the OP asked.
To use regex, put the replacment text in a match ( )
and then replace that match with nothing string.Empty
:
string text = @"werfds_tyer.abc.zip.ytu_20111223170226_20111222.20111222";
string pattern = @"(\.zip\.ytu)";
Console.WriteLine( Regex.Replace(text, pattern, string.Empty ));
// Outputs
// werfds_tyer.abc_20111223170226_20111222.20111222
txt = txt.Replace(".zip.ytu", "");
Why don't you simply do above?
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