mIRC Homepage
Posted By: tremenda Regex/caps - 15/05/07 04:24 PM
I'm not very clued up on regex, but done a bit of hunting around
Basically all i want to do is..
any caps that appear in $1- i wanted to colour them, red for instance
EX: Hello, HOW is it GOIng

i started off with something like this
Code:
on ^*:TEXT:*:#:{
var %caps $regex($1-,/[A-Z]/g)
echo -ti20 < $+ $nick $+ > %caps
}

Posted By: hixxy Re: Regex/caps - 15/05/07 06:42 PM
Code:
on ^*:TEXT:*:#:{
  echo -ti20 $+(<,$nick,>) $regsubex($1-,/[A-Z]+/g,$+($chr(3),04\t,$chr(3)))
  haltdef
}


thanks qwerty
Posted By: qwerty Re: Regex/caps - 15/05/07 07:08 PM
This is one of the cases where [A-Z]+ (instead of [A-Z]) really makes a difference (not just in efficiency, but mainly in string length).
Posted By: tremenda Re: Regex/caps - 15/05/07 07:27 PM
This actually deletes the capital letters, and leaves the lower case ones, Looks a bit odd
Posted By: qwerty Re: Regex/caps - 15/05/07 08:23 PM
Ah yes, surround [A-Z]+ in (), ie /([A-Z]+)/g
Posted By: The_JD Re: Regex/caps - 15/05/07 08:27 PM
This should work though

Code:
on ^*:TEXT:*:#:{
  echo -ti20 $+(<,$nick,>) $regsubex($1-,/([A-Z]+)/g,$+($chr(3),04\t,$chr(3),99))
  haltdef
}


* fixed regex
* added color 99 so numbers in text wont be treated as colors
Posted By: The_JD Re: Regex/caps - 15/05/07 08:30 PM
oh you beat me to it :P
Posted By: Midori Re: Regex/caps - 16/05/07 08:29 AM
why use 99 when 04 works just as well? >.<
Posted By: Sais Re: Regex/caps - 16/05/07 12:10 PM
Code:
//echo -a $+($chr(3),04,text,$chr(3),99,more text)


versus

Code:
//echo -a $+($chr(3),04,text,$chr(3),04,more text)


versus (what he was trying to avoid)
Code:
//var %text1 = 10 green bottles, %text2 = 6 bluebottles | echo -a echo -a $+($chr(3),04,%text1,$chr(3),%text2)
Posted By: The_JD Re: Regex/caps - 16/05/07 01:48 PM
Originally Posted By: Midori
why use 99 when 04 works just as well? >.<


Why? 99=Default line color. if i were to put 04 instead of 99 ALL the text would be red
Posted By: tremenda Re: Regex/caps - 16/05/07 02:23 PM
Cheers guys! grin
Posted By: Midori Re: Regex/caps - 21/05/07 03:25 AM
so.. (ctrl+k)99 == $chr(15) (ctrl+o) ?
Posted By: maroon Re: Regex/caps - 21/05/07 03:45 AM
ctrl-o also kills bold and underline
© mIRC Discussion Forums