mIRC Home    About    Download    Register    News    Help

Topic Options
#241536 - 02/05/13 05:53 AM Regex help
RuLerZ Offline
Ameglian cow

Registered: 05/04/13
Posts: 27
Hello I am currently creating a polling system and it is working fine right now using !poll option1 option2 option3 creating 3 different poll options but if I mess up and do something like !poll option 1 option 2 option 3 it will create 6 poll options.
I have been trying to make it so you can include spaces and between every comma is a different option
EX: !poll option 1, option 2, option 3
which should return 3.

I am currently doing this: $regex($2-,/\b\w+\b/g)
Thank you for any help you can provide.

Top
#241539 - 02/05/13 11:20 AM Re: Regex help [Re: RuLerZ]
Riamus2 Offline
Planetary brain

Registered: 13/10/04
Posts: 8327
Loc: MA, USA
Although you can use regex, it may be easier to just tokenize it.

Code:
on *:text:!poll *:#:{
  tokenize 44 $2-
  var %option1 = $1
  var %option2 = $2
  var %option3 = $3
}


Of course, you can shorten that and adjust it as needed. That's just an example with everything spread out so it's easy to see and understand. Also, if you are typing it on the same client as the script, you'd want to make that an on INPUT event instead, but the rest is the same.
_________________________
Invision Support
#Invision on irc.irchighway.net

Top
#241542 - 02/05/13 04:10 PM Re: Regex help [Re: Riamus2]
RuLerZ Offline
Ameglian cow

Registered: 05/04/13
Posts: 27
Thank you very much for the quick response. That will do exactly what I needed to do to get the different poll options just needed to make a bunch of if statements to find the total poll options lol. Thank you so much!!

Top
#241548 - 03/05/13 12:55 AM Re: Regex help [Re: RuLerZ]
Deega Offline
Vogon poet

Registered: 30/10/12
Posts: 164
Originally Posted By: RuLerZ
just needed to make a bunch of if statements to find the total poll options lol. Thank you so much!!

$0 will give you the number of options.
Code:
on *:text:!poll *:#:{
  tokenize 44 $2-
  var %options = $0
  var %option1 = $1
  var %option2 = $2
  var %option3 = $3
}

Top
#241565 - 03/05/13 11:14 AM Re: Regex help [Re: RuLerZ]
Riamus2 Offline
Planetary brain

Registered: 13/10/04
Posts: 8327
Loc: MA, USA
As Deega mentioned, you can use $0. Just to expand on that, 0 is used in many places in mIRC to get the total number of something. So anytime you are looking for a count for a given identifier, try replacing the item number with 0 and in most cases it will give you the total.
_________________________
Invision Support
#Invision on irc.irchighway.net

Top
#241658 - 11/05/13 12:57 AM Re: Regex help [Re: Riamus2]
RuLerZ Offline
Ameglian cow

Registered: 05/04/13
Posts: 27
Aww sweet!!! Ty so much made the code so much cleaner! you guys rock!!

Top