mIRC Home    About    Download    Register    News    Help

Print Thread
Joined: Nov 2003
Posts: 101
C
colt45 Offline OP
Vogon poet
OP Offline
Vogon poet
C
Joined: Nov 2003
Posts: 101
Not sure how or where to start...
What I'd like to do is to tell me which one has been detected.
Excuse my poor english but let me show you example what I'm trying to do and maybe you can help me solve this?
Thanks

I want to capture $1- as an example
Quote:

The quick brown fox jumps over the lazy dog

I'm hoping to use regex
i.e.
Code:
($regex($1-,/(cow|dog|fox|pigs)/i))

So in return, I'd like to display it something like this..
Quote:

Word detected : The quick brown fox jumps over the lazy dog

Hope one of you can help me out here .. thanks

Joined: Feb 2006
Posts: 546
J
Fjord artisan
Offline
Fjord artisan
J
Joined: Feb 2006
Posts: 546
you can use $regsubex() to perform substitutions on the portions of the text matched by your regular expression:

Code:
$regsubex($1-, /(cow|dog|fox|pigs)/gi, $chr(3) $+ 4\1$chr(15))


the 'g' modifier tells the regex engine to continue past the first successful match. \1 in the 3rd (substitution) parameter returns the substring captured by the first (group) in the expression.


"The only excuse for making a useless script is that one admires it intensely" - Oscar Wilde
Joined: Nov 2003
Posts: 101
C
colt45 Offline OP
Vogon poet
OP Offline
Vogon poet
C
Joined: Nov 2003
Posts: 101
That $regsubex() is exactly what i was looking for! laugh

Also, where did you find that /g switch from? - It not in the mirc.chm tho (i'm using v6.35 - will upgrade to 7.1 but too scare it might breaks my script! :p)

Many thanks for the reply tho smile

Joined: Oct 2004
Posts: 8,330
Hoopy frood
Offline
Hoopy frood
Joined: Oct 2004
Posts: 8,330
The help file doesn't list a LOT of what you can do with regex. You'll want to look up regex information with Google to find all of the things you can do with it that aren't shown in the help file.


Invision Support
#Invision on irc.irchighway.net
Joined: Nov 2003
Posts: 101
C
colt45 Offline OP
Vogon poet
OP Offline
Vogon poet
C
Joined: Nov 2003
Posts: 101
I have this bad habit as I rely on mirc.chm but will try start using google more smile

Thanks smile

Joined: Jul 2007
Posts: 1,129
T
Hoopy frood
Offline
Hoopy frood
T
Joined: Jul 2007
Posts: 1,129
Originally Posted By: colt45
where did you find that /g switch from?
The /g is a regex modifier. You can learn about it via any online search engines or local book stores to find out what it means and does. The /g modifier simply makes the regex match something you're after globally or in a "greedy" manner. Without using it, the regex will only match the first string that it finds and stops.

Joined: Nov 2003
Posts: 101
C
colt45 Offline OP
Vogon poet
OP Offline
Vogon poet
C
Joined: Nov 2003
Posts: 101
Originally Posted By: Tomao
Originally Posted By: colt45
where did you find that /g switch from?
The /g is a regex modifier. You can learn about it via any online search engines or local book stores to find out what it means and does. The /g modifier simply makes the regex match something you're after globally or in a "greedy" manner. Without using it, the regex will only match the first string that it finds and stops.


Noted smile

Thanks ..

Joined: Sep 2007
Posts: 109
K
Vogon poet
Offline
Vogon poet
K
Joined: Sep 2007
Posts: 109
Used to color the nicknames of the channel?
Code:
on *:INPUT:#: {
  if ($left($1,1) != /) { 
    .msg $active $regsubex($1-, /( $nick )/gi, $chr(3) $+ 4\1$chr(15))
  }
}

Last edited by kwell; 21/08/10 01:36 PM.
Joined: Jul 2007
Posts: 1,129
T
Hoopy frood
Offline
Hoopy frood
T
Joined: Jul 2007
Posts: 1,129
kwell, your example will fail to work.


Link Copied to Clipboard