mIRC Home    About    Download    Register    News    Help

Print Thread
Regex/caps #176870 15/05/07 04:24 PM
Joined: May 2007
Posts: 4
tremenda Offline OP
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.
Re: Regex/caps [Re: tremenda] #176873 15/05/07 06:42 PM
Joined: Sep 2005
Posts: 2,881
H
hixxy Offline
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.
Re: Regex/caps [Re: hixxy] #176875 15/05/07 07:08 PM
Joined: Jan 2003
Posts: 2,523
Q
qwerty Offline
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
Re: Regex/caps [Re: hixxy] #176876 15/05/07 07:27 PM
Joined: May 2007
Posts: 4
tremenda Offline OP
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

Re: Regex/caps [Re: tremenda] #176877 15/05/07 08:23 PM
Joined: Jan 2003
Posts: 2,523
Q
qwerty Offline
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
Re: Regex/caps [Re: tremenda] #176878 15/05/07 08:27 PM
Joined: Mar 2006
Posts: 393
T
The_JD Offline
Fjord artisan
Offline
Fjord artisan
T
Joined: Mar 2006
Posts: 393
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)
Re: Regex/caps [Re: qwerty] #176879 15/05/07 08:30 PM
Joined: Mar 2006
Posts: 393
T
The_JD Offline
Fjord artisan
Offline
Fjord artisan
T
Joined: Mar 2006
Posts: 393
oh you beat me to it :P


[02:16] * Titanic has quit IRC (Excess Flood)
Re: Regex/caps [Re: The_JD] #176906 16/05/07 08:29 AM
Joined: Feb 2006
Posts: 64
M
Midori Offline
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}
Re: Regex/caps [Re: Midori] #176910 16/05/07 12:10 PM
Joined: Oct 2003
Posts: 313
S
Sais Offline
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
Re: Regex/caps [Re: Midori] #176914 16/05/07 01:48 PM
Joined: Mar 2006
Posts: 393
T
The_JD Offline
Fjord artisan
Offline
Fjord artisan
T
Joined: Mar 2006
Posts: 393
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)
Re: Regex/caps [Re: qwerty] #176921 16/05/07 02:23 PM
Joined: May 2007
Posts: 4
tremenda Offline OP
Self-satisified door
OP Offline
Self-satisified door
Joined: May 2007
Posts: 4
Cheers guys! grin

Re: Regex/caps [Re: The_JD] #177179 21/05/07 03:25 AM
Joined: Feb 2006
Posts: 64
M
Midori Offline
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}
Re: Regex/caps [Re: Midori] #177180 21/05/07 03:45 AM
Joined: Jan 2004
Posts: 1,586
maroon Offline
Hoopy frood
Offline
Hoopy frood
Joined: Jan 2004
Posts: 1,586
ctrl-o also kills bold and underline