mIRC Home    About    Download    Register    News    Help

Print Thread
another regex question.. #103628 23/11/04 10:16 AM
Joined: Feb 2004
Posts: 119
D
da_hype Offline OP
Vogon poet
OP Offline
Vogon poet
D
Joined: Feb 2004
Posts: 119
alias swear {
return $regex($1-,/(dick)|(penis)/g)
}

when someone types "dickless" it still returns 1. how to make it return 1 when only "dick" is typed?

Re: another regex question.. #103629 23/11/04 10:26 AM
Joined: Feb 2004
Posts: 2,019
FiberOPtics Offline
Hoopy frood
Offline
Hoopy frood
Joined: Feb 2004
Posts: 2,019
Encapsulate the words with the \b, meaning word boundary. It will only trigger then if it is surrounded by a non-word character, like punctuation or a space etc.

alias swear return $regex($1-,/\b(?:dick|penis)\b/Sig)

EDIT: Check out this regex tutorial.

Re: another regex question.. #103630 23/11/04 10:45 AM
Joined: Feb 2004
Posts: 119
D
da_hype Offline OP
Vogon poet
OP Offline
Vogon poet
D
Joined: Feb 2004
Posts: 119
how would i do this?

Code:
alias spam { 
var %con = http|www
return $regex(http,/\b(?:%con)\b/Sig) 
}

Re: another regex question.. #103631 23/11/04 10:48 AM
Joined: Nov 2003
Posts: 2,327
T
tidy_trax Offline
Hoopy frood
Offline
Hoopy frood
T
Joined: Nov 2003
Posts: 2,327
Code:
alias spam { 
  var %con = http|www
  return $regex([color:red]$1[/color],/\b(?: [color:red]$+[/color] %con [color:red]$+[/color] )\b/Sig) 
}


Usage: $spam(<text to check for spamming>)

Of course, that's not really a good idea, since "http" and "www" can appear in a conversation without being spam.


New username: hixxy