I have the following code:

Code:
on *:text:*:#Channel:{
  var %c = $strip($1-), %i = 1
  while (%i <= $numtok(%c,32)) {
    if ($len($gettok(%c,%i,32)) == 3) {
      if ($read(smileys.txt, w, $mid($gettok(%c,%i,32),1,1)) && $read(separators.txt, w, $mid($gettok(%c,%i,32),2,1)) && $read(smileys.txt, w, $mid($gettok(%c,%i,32),3,1))) {
        msg # $mid($gettok(%c,%i,32),3,1) $+ $mid($gettok(%c,%i,32),2,1) $+ $mid($gettok(%c,%i,32),1,1)
      }
    }
    inc %i
  }
}


This works fine.

Basically it looks for a smiley within a string of words and if found, it msg's the channel with the same smiley but backwards. (e.g @_x turns to [email]x_@)[/email]


I have a file smilies.txt which contains these characters (on separate lines):
0Oox^-*@uòóôõöøÒÓÔÕÖØ'°ºùúûüÙÚÛÜ><»«
Any of these can be the first and last character.



And also separators.txt which contains these characters (on separate lines):
_ ¯ .
One of those has to be the middle character


How can I change the code to use regex instead? Or should I even bother? My brain can't begin to comprehend the use of it, but I would like to learn it eventually. Perhaps this would give me a jumpstart.

Any help appreciated.