Conditional Regex Replace in C# without MatchEvaluator

Posted by Buttink on Stack Overflow See other posts from Stack Overflow or by Buttink
Published on 2010-06-16T19:10:34Z Indexed on 2010/06/16 19:12 UTC
Read the original article Hit count: 256

Filed under:
|

So, Im trying to make a program to rename some files. For the most part, I want them to look like this,

[Testing]StupidName - 2[720p].mkv

But, I would like to be able to change the format, if so desired. If I use MatchEvaluators, you would have to recompile every time. Thats why I don't want to use the MatchEvaluator.

The problem I have is that I don't know how, or if its possible, to tell Replace that if a group was found, include this string. The only syntax for this I have ever seen was something like (?<group>:data), but I can't get this to work. Well if anyone has an idea, im all for it.

© Stack Overflow or respective owner

Related posts about c#

Related posts about regex