Recase() function

Things you’d like to miss in the future...
Post Reply
JohnM
Posts: 247
Joined: 08 Jun 2006 11:59
Location: Tasmania, Australia

Recase() function

Post 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
Attachments
XY Recase.PNG
XY Recase.PNG (22.24 KiB) Viewed 1209 times
Windows 8.1 x64
XYplorer 22.90.0105 beta

highend
Posts: 13274
Joined: 06 Feb 2011 00:33

Re: Recase() function

Post by highend »

One of my scripts helped you out? Please donate via Paypal

JohnM
Posts: 247
Joined: 08 Jun 2006 11:59
Location: Tasmania, Australia

Re: Recase() function

Post by JohnM »

Ah ok. Thanks Highend!
Windows 8.1 x64
XYplorer 22.90.0105 beta

admin
Site Admin
Posts: 60357
Joined: 22 May 2004 16:48
Location: Win8.1 @100%, Win10 @100%
Contact:

Re: Recase() function

Post 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.

highend
Posts: 13274
Joined: 06 Feb 2011 00:33

Re: Recase() function

Post by highend »

Another flag to disregard the entries of the tweak would be nice...
One of my scripts helped you out? Please donate via Paypal

admin
Site Admin
Posts: 60357
Joined: 22 May 2004 16:48
Location: Win8.1 @100%, Win10 @100%
Contact:

Re: Recase() function

Post 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)

JohnM
Posts: 247
Joined: 08 Jun 2006 11:59
Location: Tasmania, Australia

Re: Recase() function

Post by JohnM »

Hi Don,

I think the change is a good one, but extending the function is a great idea. Thanks 8)
Windows 8.1 x64
XYplorer 22.90.0105 beta

jupe
Posts: 2757
Joined: 20 Oct 2017 21:14
Location: Win10 22H2 120dpi

Re: Recase() function

Post 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

admin
Site Admin
Posts: 60357
Joined: 22 May 2004 16:48
Location: Win8.1 @100%, Win10 @100%
Contact:

Re: Recase() function

Post by admin »

Yep, that's a bug. Fix comes. :tup: :cup:

Post Reply