camelSplitString property

string get camelSplitString

Returns a string with camel case split into separate words.

The camel case string is split into separate words using a space as the separator. For example, "camelSplitString" will be converted to "camel Split String".

Implementation

string get camelSplitString {
  string input = this;
  StringBuffer result = StringBuffer();
  for (int i = 0; i < input.length; i++) {
    if (i > 0 && input[i].toUpperCase() == input[i] && input[i - 1].toUpperCase() != input[i - 1]) {
      result.write(' ');
    }
    result.write(input[i]);
  }
  return result.toString();
}