// 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 { class MainClass { private static Regex re = new Regex("^[A-Za-zÆØÅæøå]*$"); public static bool AllText1(string s) { return re.Match(s).Success; } private static string valid = "ABCDEFGHIHKLMNOPQRSTUVWXYZÆØÅ" + "abcdefghijklmnopqrstuvwxyzæøå"; public static bool AllText2(string s) { for(int i = 0; i < s.Length; i++) { if(valid.IndexOf(s[i]) < 0) { return false; } } return true; } public static void Test(string s) { Console.WriteLine(AllText1(s)); Console.WriteLine(AllText2(s)); } public static void Main(string[] args) { Test("ABC"); Test("123"); Test("A1"); } } }