Match Colon in String - CSharp System

CSharp examples for System:String Match

Description

Match Colon in String

Demo Code


using System.Text.RegularExpressions;
using System.Text;
using System.Globalization;
using System.Collections.Generic;
using System;/*ww  w.j av  a2 s . c o  m*/

public class Main{
        public static bool MatchColon(string string1, string string2)
        {

            string str = string1.ToLower().Trim();
            
            string string2_1 = string2.ToLower().Trim();
            
            try
            {

                if (str.ToLower().IndexOf(" - ", System.StringComparison.Ordinal) > -1)
                {

                    string string1_1 = str.ToLower().Trim().Replace(" - ", ": ");
                    
                    if (string2_1.ToLower().Trim() == string1_1.ToLower().Trim() 
                        || MatchAND(string1_1, string2_1) 
                        || MatchEndingTHE(string1_1, string2_1))
                        return true;
                
                }
                return false;
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
}

Related Tutorials