Capitalization / Initcap Hyphenated Word

I have a customer name that I use the "capitalize" function of the String Manipulation Node to make the first letter capitallzed followed by lower case letters.  That works fine.  But I want to Also capitalize the first letter after the dash character in the event of a hyphenated name.  For example "Smith-johnson" should actually read "Smith-Johnson".

My work around has been to split the column on the hyphen using Split Cell, capitalize each word, then rejoin.  But now I'm trying to create a template metanode.  And the problem is I don't know how many cells might be created by the Split Cell. I can continue to do a lot of work around like assume some maximum number, rejoin them, and then filter the columns with forced inclusion.  Im bettering someone in the forum has a better solution.

Should I consider doing a column name loop? Or some other loop that looks at the characters of a string one byte at a time?

 

Ok I partially solved my own problem.  Turns out the "capitalize" function has an optional parameter where you can specify a list of delimiters to capitalize after.  So now I use calitalize($lastname$," -'".  However I have one additional hiccup.  Scottish/Irish names like Mcdonald and Macdonald.  Those names should actually be show as McDonald and MacDonald.  I'd like to capitalize the letter following the "Mc" or "Mac".

1 Like