Add Space

Certified Associate Developer

Hii All,

I want to add space between the string and first letter in upper case like:

firstName : First Name

lastName : Last Name

Thanks

  Discussion posts and replies are publicly visible

  • 0
    Certified Lead Developer

    There are a lot of questions you'd need to answer before anyone can give you a strong answer here.

    Are you talking about a rule that would take one string (any string) as an input, and return an output where space(s) have been added?

    What is the full range of acceptable inputs?  Is it just "firstName" and "lastName", or is it literally any string?  What would the expected result be if the input has no uppercase characters? What would the expected result be if the input is only uppercase characters?  And all permutations between those possibilities?

  • 0
    Certified Senior Developer

    Hi

    Please use this expression to get the expected output

    firstName : First Name

    a!localVariables(
    local!letter: "firstName",
    local!a: joinarray(
    a!forEach(
    items: enumerate(len(local!letter)) + 1,
    expression: if(
    exact(
    fn!mid(local!letter, fv!index, 1),
    upper(fn!mid(local!letter, fv!index, 1))
    ),
    concat(" ", fn!mid(local!letter, fv!index, 1)),
    fn!mid(local!letter, fv!index, 1)
    )
    ),
    ""
    ),
    proper(local!a)
    )