Match Ending THE in String - CSharp System

CSharp examples for System:String Match

Description

Match Ending THE in String

Demo Code


using System.Text.RegularExpressions;
using System.Text;
using System.Globalization;
using System.Collections.Generic;
using System;/*from   w w w .j  a  v a 2  s. co m*/

public class Main{
        public static bool MatchEndingTHE(string string1, string string2)
        {
            string str = string1.ToLower().Trim();
            string string2_1 = string2.ToLower().Trim();
            try
            {
                if (str.ToLower().EndsWith(", the"))
                {

                    string string1_1 = str.Substring(0, str.ToLower().LastIndexOf(", the"));
                    
                    string1_1.Insert(0, "The ");
                    
                    if (string2_1.ToLower().Trim() == string1_1.ToLower().Trim() 
                        || MatchAND(string1_1, string2_1))
                        return true;
                
                }
                return false;
            }
            catch
            {
                throw;
            }
        }
}

Related Tutorials