BlueSky.CommandExecutionHelper.VarnamesToTitle C# (CSharp) Method

VarnamesToTitle() private method

private VarnamesToTitle ( string str ) : string
str string
return string
        private string VarnamesToTitle(string str) //23Apr2013
        {

            char[] chrarr = str.ToCharArray();

            bool titleexists = (Regex.IsMatch(str, @"""\s*\'") && Regex.IsMatch(str, @"\'\s*""")) ? true : false;
            if (titleexists)
            {
                MatchCollection mcstrt = Regex.Matches(str, @"""\s*'");
                MatchCollection mcend = Regex.Matches(str, @"'\s*""");
                char ch;
                if (mcstrt.Count == mcend.Count) // if formatting is correct, ie.. opening " has a matching closing "
                {
                    for (int i = 0; i < mcstrt.Count; i++)
                    {
                        int start = mcstrt[i].Index;
                        int end = mcend[i].Index;

                        /// now remove old double quotes & from start to end change all single quotes to double ///
                        for (int j = start; ; j++)
                        {
                            ch = chrarr[j];
                            if (chrarr[j] == '"')
                            {
                                chrarr[j] = ' ';
                            }
                            else if (chrarr[j] == '\'')
                            {
                                chrarr[j] = '"';
                            }
                            if (j > start && ch == '"')
                                break;
                        }
                    }
                    str = new string(chrarr);
                }
            }
            return str;
        }