// 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 regextest { class Class1 { [STAThread] static void Main(string[] args) { RegExTester t = new RegExTester(); t.CheckString("412132"); t.CheckString("asdasdgfa"); t.CheckString("asgagf134151"); } } public class RegExTester { public void CheckString(string s) { Console.WriteLine("Checking: " + s); if(s.Equals(Regex.Match(s, "[0-9]+").Value)) Console.WriteLine("String is numeric"); if(s.Equals(Regex.Match(s, "[a-zA-ZæÆøØåÅ]+").Value)) Console.WriteLine("String is alphabetic"); if(s.Equals(Regex.Match(s, "[a-zA-ZæÆøØåÅ0-9]+").Value)) Console.WriteLine("String is alphanumeric"); } } }