So after many years, I'm finally learning myself regular expressions wink

My first attempt should be a simple enough task, getting an event to trigger on your nickname, while not being part of another word (STING=true, teSTING=false)

So far I succeed with a '==' and 3 $regex'es, but I think this could probably be done by one $regex, right? smile


Code:
alias _regex {

  ;should be False
  var %text.1 = testing 

  ;should be True
  var %text.2 = test STING test 

  ;should be True
  var %text.3 = STING test 

  ;should be True
  var %text.4 = test STING 

  ;should be True
  var %text.5 = STING 

  var %tmp = 0
  clear
  while (%tmp < 5) {
    inc %tmp
    var -s %txt = %text. [ $+ [ %tmp ] ]
    if (%txt == STING) || $regex(%txt,/ STING /) || $regex(%txt,STING$) || $regex(%txt,^STING) { echo -a % $+ text. $+ %tmp is 3True }
    else { echo -a % $+ text. $+ %tmp is 4False }
  }
}