Channel Regex Tester

By sparko on May 06, 2009

SYNTAX: !regex -p

eg: !regex 127.0.0.1 -p /^\b(\d+.\d+.\d+.\d+)\b$/

Regular Expression Tester

By: Phil (#dot100 @ QuakeNet)

Bug reports/feature requests - phil@dot100.co.uk

Examples:

(@phil) !regex 127.0.0.1:27015 password de_dust2 -p /([0-9]+.[0-9]+.[0-9]+.[0-9]+\:[0-9]+) (\S+) (\S+)/
(@bot) Tested "127.0.0.1:27015 password de_dust2 -p" with pattern: /([0-9]+.[0-9]+.[0-9]+.[0-9]+\:[0-9]+) (\S+) (\S+)/ - result: 1
(@bot) Result 1: 127.0.0.1:27015
(@bot) Result 2: password
(@bot) Result 3: de_dust2
(14:43:01) (@dot100|phil) !regex a very long string or phrase to test and see if my regex works -p /(\w+)/g
(14:43:02) (+GamerFM) Tested "a very long string or phrase to test and see if my regex works" with pattern: /(\w+)/g - result: 14
(14:43:02) (+GamerFM) Result 1: a
(14:43:02) (+GamerFM) Result 2: very
(14:43:02) (+GamerFM) Result 3: long
(14:43:02) (+GamerFM) Result 4: string
(14:43:03) (+GamerFM) Result 5: or
(14:43:05) (+GamerFM) -- Result spew truncated at 5 results --

**

UPDATE: Thanks to bindi for finding the regex which crashes mIRC.

**

alias regex.threshold { !return 5 }

on *:TEXT:!regex*:#: { 
  if (!$2 || !$3) { .msg $chan Syntax: !regex <data> -p <pattern> | halt }
  var %x = 1
  while ($gettok($2-,%x,32)) { 
    if ($ifmatch == -p) { var %pos = %x }
    inc %x
  }
  if (!%pos) { .msg $chan No $qt(-p) found. | halt }
  var %data = $gettok($2-,$+(1,-,$calc(%pos - 1)),32)
  var %pattern = $gettok($2-,$+($calc(%pos + 1),-),32)
  msg $chan Tested $qt(%data) with pattern: %pattern - result: $regex(%data,%pattern)
  if (*/((?(?!a).))*/* iswm %pattern) { msg $chan Disallowed Regex. }
  if ($regex(%data,%pattern)) && ($regml(0) != 0) { 
    var %x = 1
    while ($regml(%x)) { 
      msg $chan Result %x $+ : $ifmatch
      if (%x == $regex.threshold) { msg $chan  -- Result spew truncated at $v2 results -- | break }
      inc %x
    }
  }
}

Comments

Sign in to comment.
sparko   -  May 07, 2009

Np :-)

Don't really know what it is useful for, maybe a regex channel on a small network? Thanks for the comments guys.

 Respond  
bone282   -  May 06, 2009

i like it as as well. and thanks for the comment on the php bot i made.

 Respond  
napa182   -  May 06, 2009

Anthrophobic read the Introduction they tell you what it does.
it's to test Regular Expressions
and if you still dont get it go read a tutt on regex.

nice work sparko 7/10

 Respond  
Anthrophobic   -  May 06, 2009

Ummm..what exactly does it do?

 Respond  
Are you sure you want to unfollow this person?
Are you sure you want to delete this?
Click "Unsubscribe" to stop receiving notices pertaining to this post.
Click "Subscribe" to resume notices pertaining to this post.