This is just for that user who want to 1st letter on
on 1:INPUT:*: {
set %Var3 $1-
unset %Var1 %Var2
set %Var1 1 | set %Var2 $upper($mid(%Var3,1,1))
if ($mid(%Var3,1,1) == $chr(47)) { goto ServerCommand }
if ($len(%Var3) == 1) { set %Var2 $upper(%Var2) | say %Var2 | halt }
:Start1
inc %Var1 1
if ($mid(%Var3,%Var1,1) != $chr(32)) { set %Var2 %Var2 $+ $mid(%Var3,%Var1,1) | if ($len(%Var3) < %Var1) { goto Start1 } }
if ($mid(%Var3,%Var1,1) == $chr(32)) { set %Var2 %Var2 $+ $upper($mid(%Var3,%Var1,2)) | inc %Var1 1 | if ($len(%Var3) < %Var1) { goto Start1 } }
if ($len(%Var3) != %Var1) { goto Start1 }
say %Var2
halt
:ServerCommand
}
menu channel {
All 1st Letter Caps
.on { set %script true }
.off { unset %script }
This Code Already Added In
http://www.hawkee.com/snippet/1570/
And This Guy ReAdd This Code :|
Gummo, I'm aware of that could happen, and if you want to get technical, there will always be a "what-if possibility" to take into consideration. I wasn't being meticulous when it came to matching in the regex. I was basically copying if off from the example shown above my initial post for a quick solution. Nevertheless, though, I agree with you about using the "negative lookaround" method to enhance the foolproof level of regex.
Using \w as your regex pattern by itself will match any word character after any word boundary. That means that "Jethro's" would become "Jethro'S"
For matching words alone you can use
on *:input:*: {
if ($left($1,1) !isin / $readini($mircini,text,commandchar)) && (!$ctrlenter) && (!$inpaste) {
say $regsubex($1-,/(?<!\S)(\w)/g,$+($chr(2),$upper(\1),$chr(2)))
haltdef
}
}
If you still want to match words in other places like "[Hello]" then you need a more complex check if you want to do this accurately.
Styleofglobal, I'm not sure which one you want, so these two snippets below are for you to pick:
This one below will make the first letter of each and every word in a sentence in CAPS and BOLD:
on *:input:*:{
if ($left($1,1) != /) {
haltdef
say $regsubex($1-,/(\w+)/g,$+($chr(2),$upper($left(\t,1)),$chr(2),$mid(\t,2)))
}
}
e.g. Hello Styleofglobal, I's A Beautiful Day
This one below will only make the first letter of a sentence in CAPS and BOLD:
on *:input:*:{
if ($left($1,1) !isin / $readini($mircini,text,commandchar)) && (!$ctrlenter) && (!$inpaste) {
say $regsubex($1-,/^(.)/,$+($chr(2),$upper(\1),$chr(2)))
halt
}
}
e.g. Hello Styleofglobal, it's a beautiful day.
BoosteeR Said:
Cant u make it so i only set the 1st letter in the whole sentence caps ?
um you can just use
$+($upper($left($1-,1)),$mid($1-,2))
for that try it using this alias
alias caps say $+($upper($left($1-,1)),$mid($1-,2))
but the whole point of his snippet was to make every 1st letter said a cap.
for that i would use
$regsubex($1-,/(\w+)/g,$+($upper($left(\t,1)),$mid(\t,2)))
could also do
#Caps off
on *:input:*:{
if ($left($1,1) != /) {
haltdef
say $regsubex($1-,/(\w+)/g,$+($upper($left(\t,1)),$mid(\t,2)))
}
}
#Caps end
menu channel {
.Turn All 1st. Letter Caps $iif($group(#Caps) = on,Off,On):{
$+(.,$iif($group(#Caps) = on,dis,en),able) #Caps
echo -a 1st. Letter Caps is now $group(#Caps)
}
}
may be set %Var2 $upper(%Var2) | say %Var2 | halt have to be set %Var2 $upper(%Var3) | say %Var2 | halt
but why u unset the variable you can just set it but you can use /var too
where is the condition if (%script) ????
your code can be like this
on *:input:*:{
if (%script) && ($left($1,1) != /) {
var %x 1
while $gettok($1-,%x,32) {
var %r %r $upper($left($v1,1)) $+ $mid($v1,2)
inc %x
}
say %r
halt
}
}