cancel
Showing results forย 
Search instead forย 
Did you mean:ย 

Titlecase (.titleize) Puzzle

spencerstone
Deputy Chef II
Deputy Chef II

Right now, I receive First and Last name in an Integration in the following formats: 

  1. All UPPERCASE
  2. All lowercase
  3. Correctly Formatted Names

I use the .titleize function to correct the first 2 cases and it works a charm. For case 3, 90% of the time it works well, but there is the occasional case that Workato messes up with this formula. 

Take for example someone with the name Daniel-Spaniel McBride. That is already titlecase, so I would want Workato to leave this alone. However, instead of recognizing a correctly titlecase name, it turns it into this: "Daniel Spaniel Mc Bride"

How can I prevent Workato from adding spaces where there should be special characters and messing up people's correctly formatted names, and also maintaining the CAPS -> Titlecase and lowercase -> Titlecase cadence? I want to use REGEX but I am not sure how to incorporate that into a Variable easily.... 

4 REPLIES 4

spencerstone
Deputy Chef II
Deputy Chef II

I actually think I solved my own issue.... I used ruby in the formula 

if input.match?(/\A[A-Z\s\-']+\z/) || input.match?(/\A[a-z\s\-']+\z/)
  input.titleize
else
  input
end

 Curious if anyone else has another solution though!

rajeshjanapati
Deputy Chef III
Deputy Chef III

Hi @spencerstone,

Please check this formula with Regex expression, it may works for you... namePILL.match?(/^[a-z\s]+$/) || namePILL.match?(/^[A-Z\s]+$/) ? namePILL.titleize : namePILL

for me it worked well, when I checked in recipe, with different name and also I have tried with the name given by you, getting same name without any change.

output_logger_step.pngregex_formula_img.png

Bhagya_pola
Deputy Chef III
Deputy Chef III

Hi @spencerstone 
I think you can try this way

Screenshot 2025-09-12 002504.png

shivakumara
Executive Chef III
Executive Chef III

Hi @spencerstone ,
Here is detailed solution to the asked requirements.
Example

  • The input can contain special characters either before or after alphabetic characters, or even between them. It should also handle cases where special characters appear consecutively.

    TitleLize_2.jpgTitleLize_4.jpg
     
    Thanks and Regards,
    Shivakumara K A