public static Boolean containsAny(string[] checks, string input,bool CaseSensitiveMatch = false)
string i = !CaseSensitiveMatch?input.ToLower():input;
foreach (string s in checks) {
string c = !CaseSensitiveMatch?s.ToLower():s;
public static String substitute(string[] checks, string input, string subval)
return substitute(checks,input,subval,null,false);
public static String substitute(string[] checks, string input,string subval, bool CaseSensitiveMatch = false)
return substitute(checks,input,subval,null,CaseSensitiveMatch);
public static String substitute(string[] checks, string input, string subval,string[] SurroundWith = null)
return substitute(checks,input,subval,SurroundWith,false);
public static String substitute(string[] checks, string input, string subval, string[] SurroundWith = null, bool CaseSensitiveMatch = false)
string i = !CaseSensitiveMatch?input.ToLower():o;
foreach (string s in checks) {
string c = !CaseSensitiveMatch?s.ToLower():s;
o = Stuff(o,i.IndexOf(c),c.Length,subval);
if(SurroundWith != null && SurroundWith.Length == 2)
o = surroundWith(o,SurroundWith);
public static string surroundWith(string input, string[] beforeAfter)
if(beforeAfter != null && beforeAfter.Length == 2)
b = beforeAfter.Length >= 1?beforeAfter[0]:null;
a = beforeAfter.Length >= 2?beforeAfter[1]:null;
return surroundWith(input,b,a);
public static string surroundWith(string input, string before, string after)
string o = string.Format("{0}{1}{2}",before,input,after);
public static Tuple<string,string> InternalKvp(string input,string searchKey,char[] drillPath,int startPos = 0)
if(startPos <= drillPath.Length-1)
char c = drillPath[startPos];
string[] S = input.Split(new Char[] {c},StringSplitOptions.RemoveEmptyEntries);
return new Tuple<string,string>(s,S[idx+1]);
Tuple<string,string> o = InternalKvp(s,searchKey,drillPath,startPos + 1);
public static string Stuff(string input, int start, int length, string stuffing)
return input.Remove(start, length).Insert(start, stuffing);
public static void Main()
string test01_connString = @"Data Source=HYLDA;Initial Catalog=DEMO_Telehealth_Delivery;Integrated Security=False;User ID=sa;Password=Ch0c0late;MultipleActiveResultSets=True;";
string test02_connString = @"Data Source=HYLDA;Initial Catalog=DISTRICTPOOL_Telehealth_Delivery;Integrated Security=False;User ID=sa;Password=Ch0c0late;MultipleActiveResultSets=True;";
string test01_prdPasswordResetPartial = @".emmdatareports.com/eap/passwordreset?t=";
string test02_prdPasswordResetPartial = @"eap.emmdatareports.com/{INSTANCE}/passwordreset?t=";
string Constring = test02_connString;
string location = test01_prdPasswordResetPartial;
string _lob = string.Empty;
Tuple<string,string> icTuple = u.InternalKvp(Constring,"Initial Catalog",new Char[]{';','='});
_lob = icTuple.Item2.Split(new char[]{'_'})[0].ToLower();
new string[]{"{INSTANCE}"}
,new String[]{location.StartsWith(".")?_lob:null,token}
Console.WriteLine(location);