[Sentence case] better code ?

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
White_Whale
Posts: 73
Joined: 27 Sep 2019, 01:44

[Sentence case] better code ?

07 Nov 2019, 23:45

yes, this is poor code of mine
I just wondering another/better code, for fun, nothing serious..

Code: Select all

MsgBox % RegExReplace("aBc DeF", "i)([a-z])([a-z ]+)", "$U{1}$L{2}")   ; I am not considering "Abc Def"
Thanks

[EDIT] I have changed the title of this post from "Title case" to "Sentence case"
Last edited by White_Whale on 08 Nov 2019, 00:50, edited 2 times in total.
User avatar
flyingDman
Posts: 2821
Joined: 29 Sep 2013, 19:01

Re: [Title case] better code ?

07 Nov 2019, 23:55

StringUpper has a Title Case option:

Code: Select all

clip := "aBc DeF"
StringUpper, clip, clip, T
msgbox % clip
14.3 & 1.3.7
White_Whale
Posts: 73
Joined: 27 Sep 2019, 01:44

Re: [Title case] better code ?

08 Nov 2019, 00:20

@flyingDman
Thanks comment
But
Nop, As I wrote clearly (using code line comment), that is not I wanted. I have tested it already so I wrote that comment.

That shows the same result with

Code: Select all

MsgBox % RegExReplace("aBc DeF", "i)([a-z ]+)", "$T{1}")
User avatar
boiler
Posts: 17044
Joined: 21 Dec 2014, 02:44

Re: [Title case] better code ?

08 Nov 2019, 00:46

@White_Whale, FYI - It wasn't as clear as you might think since the subject says title case. What you are looking for where only the first word is capitalized is known as sentence case.
White_Whale
Posts: 73
Joined: 27 Sep 2019, 01:44

Re: [Title case] better code ?

08 Nov 2019, 00:48

@boiler thanks good comment. I have not know that the pharse "Sentence case" up until now. I'll change the name of this post properly, as you mentioned
White_Whale
Posts: 73
Joined: 27 Sep 2019, 01:44

Re: [Title case] better code ?

08 Nov 2019, 00:53

boiler wrote:
08 Nov 2019, 00:46
@White_Whale, FYI - It wasn't as clear as you might think since the subject says title case. What you are looking for where only the first word is capitalized is known as sentence case.
actually, the first character is capitalized
User avatar
boiler
Posts: 17044
Joined: 21 Dec 2014, 02:44

Re: [Sentence case] better code ?

08 Nov 2019, 01:00

Actually, it is said that a word is capitalized when the first letter of the word is capitalized. As in the rule "all proper nouns are capitalized." That rule doesn't mean "bill" should be "BILL". It means it should be "Bill". And it is generally not said that characters are capitalized. Letters and words are capitalized.
White_Whale
Posts: 73
Joined: 27 Sep 2019, 01:44

Re: [Sentence case] better code ?

08 Nov 2019, 01:01

You win
I lose
Very nice
White_Whale
Posts: 73
Joined: 27 Sep 2019, 01:44

Re: [Sentence case] better code ?

08 Nov 2019, 01:35

so
You do not have any idea about the topic ?
You just want to win at off-topic phrase wars ?
User avatar
boiler
Posts: 17044
Joined: 21 Dec 2014, 02:44

Re: [Sentence case] better code ?

08 Nov 2019, 08:20

I'm not interested in any war. I simply offered corrections to your replies to flyingDman's and my posts. All of our posts were correct and matter of fact, and your replies were for some reason confrontational -- a somewhat harshly worded reply to him and talking about winning/losing/war to me. You may want to read back through all the posts and see whose posts could have been written in a more cordial manner.

Here is some code since you asked:

Code: Select all

MsgBox, % SentenceCase("aBc DeF")

SentenceCase(s) {
	StringLower, s, s
	return Chr(Asc(SubStr(s, 1, 1)) - 32) . SubStr(s, 2)
}
White_Whale
Posts: 73
Joined: 27 Sep 2019, 01:44

Re: [Sentence case] better code ?

08 Nov 2019, 15:53

캡처.PNG
캡처.PNG (201.51 KiB) Viewed 1538 times
gregster
Posts: 9056
Joined: 30 Sep 2013, 06:48

Re: [Sentence case] better code ?

08 Nov 2019, 16:09

Hey White_Whale (aka IMEime aka Klarion),
my impression is that you are finally, but quickly, going off the rails again - like with your previous (now retired) accounts. Not only in this thread...

I would recommend to tone down your aggressions a bit, take a step back, perhaps have a nice relaxing tea and then only start posting again, if you feel like you want to be part of this community. Thank you very much and have a nice and calm weekend!
White_Whale
Posts: 73
Joined: 27 Sep 2019, 01:44

Re: [Sentence case] better code ?

08 Nov 2019, 16:15

thanks
I will as always (I have some more "AKA"s than you know..)
gregster
Posts: 9056
Joined: 30 Sep 2013, 06:48

Re: [Sentence case] better code ?

08 Nov 2019, 16:26

Well, I know at least one more sleeper account of yours (I, for now, concentrated on mentioning your main (banned) accounts).

May I make you aware of the forum rules - for example, but not only:
Behaviour
[...]
2. Do not create multiple accounts - if you inadvertently created multiple accounts then contact a moderator to close the unwanted ones.

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: Aqualest, Bing [Bot], Google [Bot], Rohwedder, Spawnova and 351 guests