Hey,

The way your main regex works is that it looks for various regex expression which are not bound to any position/character, for example [fs]uck would only match 'suck' in #popsicles_sucking, and some of the expression are using quantifiers, like .*, which is slow, and incorrect in this case.

Quantifier are by default greedy in regex, the expression "a.*b" on the string "a01b23b" matches "a01b23b", not " a01b". This is very important. You can make a quantifier non greedy by adding a ? after it, "a.*?b" matches only "a01b".

Specifically using * on the dot '.' character is bad here because if you wanted to ban the expression "badXXchannel" where XX represent any string but you use "bad.*channel", it would match for example on "#thisisabad #chan1 #more #whateverchannel" for the same reason as above, while you want it to look for a channel name, not anywhere.

To limit each sub alternative to search only for a channel name, you should replace all the .* by [^ ]* which means anything but a space, that way it will stop when a new channel name starts.

To avoid matching in the middle of a channel name and because you're looking for the exact channel name, you also need to bound your expression to the start of the string or a space, and the end of the string or a space.
Also it looks like you're using () not to capture but to create group, in which case (?:) should be used instead.
Then /g must be used in order to match all the bad channel, then $regml() is used to get all the channel, we use one pair of () to capture what we want, and we use (?:) when we need to group but don't want to capture



Code
Raw 319:*: {
  if ($regex(save, $+ $regsubex($remove($3-,~,&,@,%,+,$chr(35)),/(.)\1+/g,\1) $+ ,/(?<=^| )([fs]uck|s[3e]x|h[^ ]*rd[^ ]*c[^ ]*ck|l[0o]v[3e]r|Pr[3e]gn[^ ]*t|b[l1i\x7C]g[^ ]*m[3e][l1i\x7C][l1i\x7C][^ ]*ns|ba[l1i\x7C][^ ]*s[^ ]p|k[^ ]*nky[^ ]*d[^ ]*sir[^ ]*|m[il1][il1]ky[^ ]*b[0o][0o]b|Pant[il1]|R[0o]l[3e]P[l1i][^ ]*Y|Er[o0]t[^ ]*c|[3e]r[3e]ct[l1i\x7C][0o]n|xxx|d[^ ]*min[^ ]*nt|[csf]uck|s[3e][k]s|$&
 $+ [lI\x7C][ae3][ae3]th[3e]r|[l1i\x7C]nj[3e]ct[l1i\x7C][0o]n|m[3ea]r[1il\x7C][3e]d|masag[3e]|s[3e]x|m[a3e]s[s][a3e]g[3e]|p[0o]rn|m[^ ]*shr[0o][0o]m|w[[1li\x7c]f[3e]|drunk|b[0o]dy[^ ]*m[^ ]*ss[^ ]*g[3e]|fr[^ ]*m[^ ]*(?:b[^ ]*h[^ ]*nd)|t[^ ]*n[^ ]*ght[^ ]*(?:w[^ ]*f[^ ]*|g[il\x7c]r[^ ]*|w[^ ]*m[^ ]*n)|d[il\x7c]ck|cucumb[3e]r|$&
 $+ my[^ ]*(?:h[0o]t|s[^ ]*x|pr[3e]gnt|s[1li\x7c]s|w[1li\x7c]f[3e]|m[0ou]m)|(h[0o]t|pr[3e]gnt|badw[0o]rd|s[1li\x7c]s|w[1li\x7c]f[3e]|m[0ou]m)[^ ]*f[ae3]nt[ae3]sy)(?= |$)/ig)) {
    VAR %bchans = $regsubex($str(#a $+ $chr(32),$regml(save,0)),/a/g,$regml(save,\n))
    VAR %t = $comchan($2,0)
    WHILE (%t) {
      var %chanz1 = $comchan($2,%t) 
      IF ($nick(%chanz1,$me,@&~%)) {
        mode %chanz1 +b $address($2,4)  
        kick %chanz1 $2 your on a banned channel ( $+ %bchans $+ ) leave it and rejoin.
      }
      DEC %t
    }
  }
}
untested.


#mircscripting @ irc.swiftirc.net == the best mIRC help channel