want to convert "indiaChinaFrance" to "India China France"

Certified Senior Developer

want to display dynamic field name on screen but with updating initial as capital and adding one space in between.Field name always start with small caps

eg. "indiaChinaFrance" to "India China France"

eg. abcDefXyz to "Abc Def Xyz"

  Discussion posts and replies are publicly visible

Parents
  • I'm sure there are easier ways (awaits others to gleefully provide simpler solutions) but here's my offering:

    a!localVariables(
      local!items: { "A", "B", "C", "D", "E", "F" },
      local!splitAttribute: fn!reduce(fn!split, ri!attributeName, local!items),
      a!forEach(
        items: local!splitAttribute,
        expression: if(
          fv!isFirst,
          fn!proper(fv!item),
          fn!concat(
            ri!attributeName[fn!find(fv!item, ri!attributeName, 1) - 1],
            fv!item
          )
        )
      )
    )

    The idea is to have the full set of characters that you want to use as delimiters in the string you want to process (I've only provide A-F as an example).

    You then split the incoming string based upon that list. Unfortunately (j this instance) the split function excludes the value you're splitting, so you up wiht a list where the first item is whole but the remaining items are missing their first character. 

    The aim of the remainder of the code is to re-append the missing character to each item in the list generated by the split processing.

  • 0
    Certified Lead Developer
    in reply to Stewart Burchell

    Assuming we'll always (and only) split on uppercase characters versus lowercase characters, this seems like a good place to (ab)use code() and char() conversions...

Reply Children