Processing Ajax...

Title
Close Dialog

Message

Confirm
Close Dialog

Confirm
Close Dialog

Confirm
Close Dialog

Replace Special Characters with Hyphens

Description
Replaces special characters with hyphens. Useful for cleaning up file names.
Language
C#.net
Minimum Version
Created By
Eric J
Contributors
-
Date Created
Aug 19, 2014
Date Last Modified
Sep 4, 2015

Macro Code

using System;

public static class ClipboardFusionHelper
{
    public static string ProcessText(string text)
    {
             return text.Replace(" ","-")     //space
                        .Replace(":","-")     //colon
                        .Replace(";","-")     //semi-colon
                        .Replace("\\","-")    //Backslash
                        .Replace("/","-")     //Slash
                        .Replace("&","-")     //Ampersand
                        .Replace("%","-")     //Percent
                        .Replace("?","-")     //QuestionMark
                        .Replace("—","-")     //Em dash
                        .Replace("–","-")     //En dash (kindof redundant)
                        .Replace("“","-")     //Smart Quote
                        .Replace("”","-")     //Smart Quote
                        .Replace("’","-")     //Typographic apostrophe
                        .Replace("[","-")     //Left Bracket
                        .Replace("]","-")     //Right Bracket
                        .Replace("®","-")     //Registered TradeMark
                        .Replace("*","-")     //star
                        .Replace("#","-");    //number sign / pound / hash / Octothorp
    }
}