101
Script / Re: Title Case
« on: July 06, 2018, 13:34:17 »
Thanks for the replies.
I am using StrToUpper and StrSub . The trouble probably is my finding the right approach.
This was a way I'd looked at word capitalization, but a regex gives me all the instances quicker.
Via regex I can have the number of instances output, hence my search for a regex replace function.
Using StrRegExpFind & a simple \s[a-z] gives me all the lower case words, I should in theory be able to take each instance ($1 $2 etc) & handle it with the StrToUpper - but that doesn't seem to be possible (tho it may be just me not getting the <str> &/or <arr> code right!) so I wondered if there might be a StrRegExpReplace function...
Can I pass the instances found by StrRegExpFind to the StrToUpper function?
The exception list should be straight forward enough - I can just run them one by one, would be nice if I could pass the exception array as in the C# above tho! The C# seems to require a lot less steps to achieve the result.
My plan was
I don't know if I'm misunderstanding you Mathias ref - ToTitleCase - could just be how the author has labelled the process the code invokes & displays on the GUI as opposed to a specific C# function....?
The idea was to take a title eg
ANT-MAN AND THE WASP | ant-man and the wasp | Ant-Man And The Wasp
& convert it to Title Case = Ant-Man and the Wasp
(Altho I think in this case it may need to be Ant-Man and The Wasp... )
This process obviously applies to many titles where simply using Camel-Case doesn't look pretty/over-emphasizes secondary prepositions etc.
I liked the idea so thought it might be fun (!) to try to recall how to script with MS
I am using StrToUpper and StrSub . The trouble probably is my finding the right approach.
This was a way I'd looked at word capitalization, but a regex gives me all the instances quicker.
Code: [Select]
...
@var $arrN = StrSplit( $NameA, " ");
@var $Words = $arrN[1];
@var $Char1 = StrSub($Words, 0, 1);
@var $arrN1 = StrToUpper($Char1);
...
Via regex I can have the number of instances output, hence my search for a regex replace function.
Using StrRegExpFind & a simple \s[a-z] gives me all the lower case words, I should in theory be able to take each instance ($1 $2 etc) & handle it with the StrToUpper - but that doesn't seem to be possible (tho it may be just me not getting the <str> &/or <arr> code right!) so I wondered if there might be a StrRegExpReplace function...
Can I pass the instances found by StrRegExpFind to the StrToUpper function?
The exception list should be straight forward enough - I can just run them one by one, would be nice if I could pass the exception array as in the C# above tho! The C# seems to require a lot less steps to achieve the result.
My plan was
- acquire the selected file name(s)
- select the words ignoring 1st word
- all words to lower case
- capitalize all words
- find words in the exception list & make them lower case
- write the new title case string to the filename.
I don't know if I'm misunderstanding you Mathias ref - ToTitleCase - could just be how the author has labelled the process the code invokes & displays on the GUI as opposed to a specific C# function....?
The idea was to take a title eg
ANT-MAN AND THE WASP | ant-man and the wasp | Ant-Man And The Wasp
& convert it to Title Case = Ant-Man and the Wasp
(Altho I think in this case it may need to be Ant-Man and The Wasp... )
This process obviously applies to many titles where simply using Camel-Case doesn't look pretty/over-emphasizes secondary prepositions etc.
I liked the idea so thought it might be fun (!) to try to recall how to script with MS