Hi everyone,
I'm working on a script to loop through different cases with the same hotkey.
For that I need to detect the case a string is in.
I've googled a lot, but I failed to find a way in autohotkey to check for title case, something like the istitle() in python.
E.g.:
'This Is @ Symbol. >> true
99 Is A "Number"! >> true
PYTHON >> false
I will be really glad for any suggestions.
Best,
PJ
equivalent of istitle() in python? Topic is solved
Re: equivalent of istitle() in python?
I'd guess you've to go with RegEx… . A quite crude workaround would be probably a construct of SubStr(), if var is lower/upper
Re: equivalent of istitle() in python? Topic is solved
thx for the quick reply!
I've got a better solution now with the help from discord:
Code: Select all
isTitleCase(param_input) {
StringUpper, OutputVar, % param_input, T
if (OutputVar == param_input) {
return true
}
return false
}
Re: equivalent of istitle() in python?
Example using Format()
Code: Select all
isTitleCase(param_input) {
if (Format("{:T}", param_input) == param_input)
return true
return false
}
- flyingDman
- Posts: 2848
- Joined: 29 Sep 2013, 19:01
Re: equivalent of istitle() in python?
shorter:
and marginally faster (but not faster than the Stringupper one...)
Code: Select all
isTitleCase(param_input) {
return Format("{:T}", param_input) == param_input
}
14.3 & 1.3.7
Who is online
Users browsing this forum: peter_ahk and 390 guests