Tinderbox Forum

Would like to convert string to proper case, e.g. convert michael becker to Michael Becker

Is there a proper case dot operator for Tinderbox? Also, what would be the best way to remove the “.” and keep the name, .e.g. michael.becker to Michael Becker.

"michael becker".capitalize() ➛ "Michael Becker"
"michael.becker".replace("\."," ") ➛ "michael becker"

Note that, in the second example, we need to escape the period (.) because the first argument is a regular expression, and without the backslash this would replace each character with a space.

1 Like

Further to the last, I’d simply note that simple names are simple to process, but many are not: q.v. the last/family name ‘de Sales la Terrière’. Perfectly valid last name, certainly here in UK. But, it is perhaps beyond what it is reasonable to expect a simply utility string function like .capitalize() to cope with correctly in all cases.

So, names are hard, as this article shows: Falsehoods Programmers Believe About Names - With Examples - Shine Solutions Group

A linked issue, apart form (correctly) letter case, is sorting. Does ‘van Dam’ sort on ‘v’ or ‘d’. Turns out there are rules but they often vary by (language) locale. As an English-speaker it’s an easy low-ball to say “who cares about accents, pre-/post-nominals?” but others might look askance. Add to the mix that some Asian countries write their names in last/First order and hilarity ensures.

The short take on this? Correct or consistent? Pick one (at least within most folks time budget). Still, finding I’ve mangled a name I misunderstood (though lack of knowledge of a different locale) always leaves me a bit down.

So, ‘mistakes’ will happen. The nature of the project will dictate the degree to which (manual) fixes make sense.

1 Like

A solution I sometimes use for tasks like these is to use an attribute to hold the data, and to tentatively assign the attribute’s initial value by an action:

$LastName|=lastWord($Name)

This works a lot of the time. When it’s wrong (Andries van Dam, G. E. M. de Ste. Croix, Henry VII), I simply enter the correct value manually.

1 Like

I concur heartily. If the correctness of the output matters, sometimes an element of manual review is needed.

1 Like