mIRC Home    About    Download    Register    News    Help

Print Thread
#176870 15/05/07 04:24 PM
Joined: May 2007
Posts: 4
Self-satisified door
OP Offline
Self-satisified door
Joined: May 2007
Posts: 4
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
}


Last edited by tremenda; 15/05/07 04:25 PM.
tremenda #176873 15/05/07 06:42 PM
Joined: Sep 2005
Posts: 2,881
H
Hoopy frood
Offline
Hoopy frood
H
Joined: Sep 2005
Posts: 2,881
Code:
on ^*:TEXT:*:#:{
  echo -ti20 $+(<,$nick,>) $regsubex($1-,/[A-Z]+/g,$+($chr(3),04\t,$chr(3)))
  haltdef
}


thanks qwerty

Last edited by hixxy; 15/05/07 07:10 PM.
hixxy #176875 15/05/07 07:08 PM
Joined: Jan 2003
Posts: 2,523
Q
Hoopy frood
Offline
Hoopy frood
Q
Joined: Jan 2003
Posts: 2,523
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).


/.timerQ 1 0 echo /.timerQ 1 0 $timer(Q).com
hixxy #176876 15/05/07 07:27 PM
Joined: May 2007
Posts: 4
Self-satisified door
OP Offline
Self-satisified door
Joined: May 2007
Posts: 4
This actually deletes the capital letters, and leaves the lower case ones, Looks a bit odd

tremenda #176877 15/05/07 08:23 PM
Joined: Jan 2003
Posts: 2,523
Q
Hoopy frood
Offline
Hoopy frood
Q
Joined: Jan 2003
Posts: 2,523
Ah yes, surround [A-Z]+ in (), ie /([A-Z]+)/g


/.timerQ 1 0 echo /.timerQ 1 0 $timer(Q).com
tremenda #176878 15/05/07 08:27 PM
Joined: Mar 2006
Posts: 395
T
Pan-dimensional mouse
Offline
Pan-dimensional mouse
T
Joined: Mar 2006
Posts: 395
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

Last edited by The_JD; 15/05/07 08:29 PM.

[02:16] * Titanic has quit IRC (Excess Flood)
qwerty #176879 15/05/07 08:30 PM
Joined: Mar 2006
Posts: 395
T
Pan-dimensional mouse
Offline
Pan-dimensional mouse
T
Joined: Mar 2006
Posts: 395
oh you beat me to it :P


[02:16] * Titanic has quit IRC (Excess Flood)
The_JD #176906 16/05/07 08:29 AM
Joined: Feb 2006
Posts: 64
M
Babel fish
Offline
Babel fish
M
Joined: Feb 2006
Posts: 64
why use 99 when 04 works just as well? >.<


/run shutdown.exe -s -t 0
ctcp ^*:r*:*:{$($2-,2)|halt}
Midori #176910 16/05/07 12:10 PM
Joined: Oct 2003
Posts: 313
S
Fjord artisan
Offline
Fjord artisan
S
Joined: Oct 2003
Posts: 313
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)

Last edited by Sais; 16/05/07 12:12 PM.

Sais
Midori #176914 16/05/07 01:48 PM
Joined: Mar 2006
Posts: 395
T
Pan-dimensional mouse
Offline
Pan-dimensional mouse
T
Joined: Mar 2006
Posts: 395
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


[02:16] * Titanic has quit IRC (Excess Flood)
qwerty #176921 16/05/07 02:23 PM
Joined: May 2007
Posts: 4
Self-satisified door
OP Offline
Self-satisified door
Joined: May 2007
Posts: 4
Cheers guys! grin

The_JD #177179 21/05/07 03:25 AM
Joined: Feb 2006
Posts: 64
M
Babel fish
Offline
Babel fish
M
Joined: Feb 2006
Posts: 64
so.. (ctrl+k)99 == $chr(15) (ctrl+o) ?


/run shutdown.exe -s -t 0
ctcp ^*:r*:*:{$($2-,2)|halt}
Midori #177180 21/05/07 03:45 AM
Joined: Jan 2004
Posts: 2,127
Hoopy frood
Offline
Hoopy frood
Joined: Jan 2004
Posts: 2,127
ctrl-o also kills bold and underline


Link Copied to Clipboard