Posted By

tranvinhnt on 02/18/08


regex valid replace filename

Versions (?)

Who likes this?

1 person have marked this snippet as a favorite


Replace invalid to valid file name

 / Published in: C#

Replace invalid to valid file name by using RegEx

  1. static string removeBadChar(string filename)
  2. {
  3. // Replace invalid characters with "_" char.
  4. return Regex.Replace(filename, @"[^\w\.-]", "_");
  6. }

Report this snippet  


RSS Icon Subscribe to comments
Posted By: Jacky888 on October 17, 2018

the 8 best lithium ion aa batteries best2by

You need to login to post a comment.