gooshie commented on a Page, Regex Swear Kicker  -  Oct 05, 2009
$regex($1-,/^(\bwordA\b|\bwordB\b|\bwordC\b)$/giS)

is functionally equivalent to:

$regex($1-,/^(wordA|wordB|wordC)$/iS)

Both the above expressions match only on wordA OR wordB OR wordC. If any other text preceeds or follows the word it will not match. Even if more exact matches are part of the string. The \b word boundary is unnecessary because with ^ it must begin with wordA OR wordB OR wordC and with $ it must also end with it. The g switch is unnecessary because it can only match a single word anyway. Of course the i switch ignores case and the S switch strips mIRC control codes. Also for a 'swear kicker' the g switch is not really needed because if it matches it does not need to continue searching and go ahead and kick.

http://xkcd.com/208/

Try this for testing purposes:

; usage: /rx wordA wordc blahwordBlah
alias rx {
  linesep
  if $regex($1-,/^(\bwordA\b|\bwordB\b|\bwordC\b)$/giS) { echo -a original: $1- }
  if $regex($1-,/^(wordA|wordB|wordC)$/iS) { echo -a exact match: $1- }
  if $regex($1-,/(\bwordA\b|\bwordB\b|\bwordC\b)/giS) {
    var %i 1,%r
    while $regml(%i) {
      %r = %r $v1
      inc %i
    }
    echo -a word match: %r
  }
  if $regex($1-,/(wordA|wordB|wordC)/giS) {
    var %i 1,%r
    while $regml(%i) {
      %r = %r $v1
      inc %i
    }
    echo -a string match: %r
  }
  linesep
}
 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.