开发者

How to Combine Regex Lines into Single Regex to Remove Space and . in C#

How can I combine the following Regex into a single one to remove all spaces and periods in the file? I figured out how to replace a single char, but not multiple characters in a single line.

    开发者_开发问答    string testfile = @"C:\test\work\A Nightmare.On.Elm Street 1984.720p.BRRip.nfo";
        testfile = testfile.Substring(0, testfile.Length - 4);
        testfile = Regex.Replace(testfile, @"\.", "");
        testfile = Regex.Replace(testfile, @"\s", "");

Thanks!


The regex to use is @"[\s\.]"

testfile = Regex.Replace(testfile, @"[\s\.]", "");


Try this:

testfile = Regex.Replace(testfile, @"[.\s]", "");
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜