// Collection of code snippets by Arne Vajhøj // (likely posted to comp.os.vms/INFO-VAX, INFO-TPU, MACRO32, eksperten.dk, newz.dk, LinkedIn or other place sometime between 1990 and now) using System; using System.Text.RegularExpressions; namespace E { public class Program { private static readonly Regex dbid = new Regex("[^A-Za-z0-9]+", RegexOptions.Compiled); public static string Str2DBID(string s) { return dbid.Replace(s, ""); } private static void Test(string s) { Console.WriteLine(s); Console.WriteLine(Str2DBID(s)); } public static void Main(string[] args) { Test("abc"); Test("a b c"); Test("a_b_c"); } } }