Page 1 of 1

Recase() function

Posted: 06 Jul 2021 23:16
by JohnM
Hi All,

I apologise if this has been asked elsewhere.

The recase() function doesn't work the way I expect when doing title case.

In the below example I expected the result to be: "Bbc The Making Of King Arthur" which would fall in line with the help. See attachment.

Am I misinterpreting what recase() should do or is there a setting I need to change?

Cheers
John

Re: Recase() function

Posted: 06 Jul 2021 23:26
by highend

Re: Recase() function

Posted: 06 Jul 2021 23:30
by JohnM
Ah ok. Thanks Highend!

Re: Recase() function

Posted: 07 Jul 2021 12:38
by admin
JohnM wrote: 06 Jul 2021 23:30 Ah ok. Thanks Highend!
Are you unhappy with the changes? I might extend SC recase() to give you more control.

Re: Recase() function

Posted: 07 Jul 2021 12:49
by highend
Another flag to disregard the entries of the tweak would be nice...

Re: Recase() function

Posted: 07 Jul 2021 13:37
by admin
Went this way:

Code: Select all

    + SC recase enhanced: Added parameter "title_case_exceptions".
      Syntax: recase(string, [mode], [flags], [title_case_exceptions])
        title_case_exceptions:
          missing: Use the global defaults (as stored at key RenameTitleCaseExceptions)
          empty: Do not use any exceptions
          else: Use this ";"-separated list of exceptions, e.g. "a;an;the"
      Examples for Title Case:
        text recase("the caMel BITES the horse.", "t");                 //The Camel Bites the Horse. (factory default exceptions)
        text recase("the caMel BITES the horse.", "t", , "");           //The Camel Bites The Horse. (no exceptions)
        text recase("the caMel BITES the horse.", "t", , "the;bites");  //The Camel bites the Horse. (custom exceptions)
      Examples for Camel Case:
        text recase("the caMel BITES the horse.", "c");                 //The CaMel BITES the Horse. (factory default exceptions)
        text recase("the caMel BITES the horse.", "c", , "");           //The CaMel BITES The Horse. (no exceptions)
        text recase("the caMel BITES the horse.", "c", , "the;bites");  //The CaMel bITES the Horse. (custom exceptions)

Re: Recase() function

Posted: 07 Jul 2021 22:11
by JohnM
Hi Don,

I think the change is a good one, but extending the function is a great idea. Thanks 8)

Re: Recase() function

Posted: 22 Jul 2022 01:31
by jupe
Don, I have a query on the new behavior of recase, when it is used with a string that has a period in it, the function seems to always make the last word lowercase (maybe assumes its an extension?), should that happen even when the flag is not set? eg:

Code: Select all

 text recase("word.word.word.word", "t");	// EXPECT ALL TO BE TITLE CASE
 text recase("word.word.word.word", "t", 1);	// EXPECT ALL EXCEPT LAST WORD TITLE CASE

Re: Recase() function

Posted: 22 Jul 2022 09:15
by admin
Yep, that's a bug. Fix comes. :tup: :cup: