Proper() not capitalizing Names with special characters

Certified Associate Developer

Hi All,

I'm not having the desired result when using proper() with words including special characters.  We receive the error when the user's name has special characters. 

EXP)  O'Neal is being saved as O'neal, Aube-Kubel as Aube-kubel, etc.

I need to implement a rule for capitalizing letters after special characters, but not sure how to proceed.  Any assistance is appreciated, thanks!

  Discussion posts and replies are publicly visible

Parents
  • 0
    Certified Lead Developer

    Maybe this works for you.

    I use a regex to find all first characters at word boundaries. The function returns the start and end positions of the matches. Then I increase the start positions by one as it is zero based. 

    I then use reduce() to iterate on the list of start positions to replace that character by its upper case version.

    Any better version is welcome.

    a!localVariables(
      local!texts: {"o'neal", "aube-kubel"},
      a!forEach(
        items: local!texts,
        expression: reduce(
          rule!SSH_Upper(_,_),
          fv!item,
          tointeger(regexsearch("(\b[a-zA-Z](?!\s))", fv!item, "gms", false).startPosition) + 1
        )
      )
    )

    My helper expression:

    fn!replace(ri!string, ri!index, 1, upper(ri!string[ri!index]))

Reply
  • 0
    Certified Lead Developer

    Maybe this works for you.

    I use a regex to find all first characters at word boundaries. The function returns the start and end positions of the matches. Then I increase the start positions by one as it is zero based. 

    I then use reduce() to iterate on the list of start positions to replace that character by its upper case version.

    Any better version is welcome.

    a!localVariables(
      local!texts: {"o'neal", "aube-kubel"},
      a!forEach(
        items: local!texts,
        expression: reduce(
          rule!SSH_Upper(_,_),
          fv!item,
          tointeger(regexsearch("(\b[a-zA-Z](?!\s))", fv!item, "gms", false).startPosition) + 1
        )
      )
    )

    My helper expression:

    fn!replace(ri!string, ri!index, 1, upper(ri!string[ri!index]))

Children
No Data