• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 248
  • Last Modified:

String Manipulation and CamelCase strings

hi,
i am trying to break a camel cased string into it's various words.

I pass in "thisIsAnExmaple" and wish to get out "This Is An Exmaple" but i am failing. can anyone see what i am doing wrong?

CODE:
private string ResolveCamelCase(string input)
            {                  
                  for (int i = input.Length - 1; i > 0; i--)
                  {
                        char original
                        if (input[i].ToString() == input[i].ToString().ToUpper())
                        {
                              input.Insert(i, " ");
                        }
                  }
                  input = input[0].ToString().ToUpper() + input.Substring(1);

                  return input;
            }
0
cossy74
Asked:
cossy74
1 Solution
 
Guy Hengel [angelIII / a3]Billing EngineerCommented:
please try thise regular expression replace:
input= Regex.Replace(input, "[A-Z]", " $1");
0
 
aponcealbuerneCommented:
Hi try with
private string ResolveCamelCase(string input)
            {
                String output = input;
                  for (int i = input.Length - 1; i > 0; i--)
                  {
                        //char original
                        if (input[i].ToString() == input[i].ToString().ToUpper())
                        {
                            output = input.Insert(i, " ");
                            input = output;
                        }
                  }
                  input = input[0].ToString().ToUpper() + input.Substring(1);

                  return output;
            }
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now