// 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; namespace DefaultNamespace { class MainClass { public static string BeforeOperator(string s) { int ix = s.IndexOf("="); if(ix < 0) { ix = s.IndexOf("<>"); } if(ix < 0) { ix = s.IndexOf(">"); } if(ix < 0) { ix = s.IndexOf("<"); } return s.Substring(0, ix).Trim(); } public static string AfterOperator(string s) { int len = 1; int ix = s.IndexOf("="); if(ix < 0) { ix = s.IndexOf("<>"); len = 2; } if(ix < 0) { ix = s.IndexOf(">"); } if(ix < 0) { ix = s.IndexOf("<"); } return s.Substring(ix + len).Trim(); } public static void Main(string[] args) { string s = "felt <> 'værdi'"; string s1 = BeforeOperator(s); Console.WriteLine(s1); string s2 = AfterOperator(s); Console.WriteLine(s2); } } }