CSharp examples for System:String Match
Match AND (&) in String
using System.Text.RegularExpressions; using System.Text; using System.Globalization; using System.Collections.Generic; using System;/*from www .j a va 2s . c o m*/ public class Main{ public static bool MatchAND(string string1, string string2) { string str1 = string1.ToLower().Trim(); string str2 = string2.ToLower().Trim(); try { if (str1.IndexOf("&") > -1) { if (str1.IndexOf(" & ") > -1) { string str3 = str1.Replace("&", "and"); if (str2.ToLower().Trim() == str3.ToLower().Trim()) return true; } else { string str3 = str1.Replace("&", " and "); if (str2.ToLower().Trim() == str3.ToLower().Trim()) return true; } } else if (str1.ToLower().IndexOf(" and ") > -1) { string str3 = str1.Replace(" and ", " & "); if (str2.ToLower().Trim() == str3.ToLower().Trim()) return true; } return false; } catch { throw; } } }