mIRC Home    About    Download    Register    News    Help

Print Thread
$iif within $regex #133241 18/10/05 10:50 AM
Joined: Jul 2005
Posts: 56
W
whoami Offline OP
Babel fish
OP Offline
Babel fish
W
Joined: Jul 2005
Posts: 56
Hello ppl,

I've hust made this code to know how much lines does a user wrote:
alias fnick { filter -gwf $active nul /^<(?i) $+ $1 $+ >\s.+/g | echo 2 -a * $1 wrote $filtered lines. }

but the problem is there are sometimes prefixs beside their nicks and i cant skip them:
<@big> blah ...etc
<whoami> @@
* big wrote 0 lines.
* whoami wrote 13 lines.

Re: $iif within $regex #133242 18/10/05 11:00 AM
Joined: Sep 2005
Posts: 2,878
H
hixxy Offline
Hoopy frood
Offline
Hoopy frood
H
Joined: Sep 2005
Posts: 2,878
Try this:

Code:
alias fnick { 
  filter -gwf $active nul /^&lt;[\Q $prefix \E]? $1 &gt;\s.+/ix 
  echo 2 -a * $1 wrote $filtered lines. 
}

Re: $iif within $regex #133243 18/10/05 11:04 AM
Joined: Aug 2003
Posts: 314
S
Sigh Offline
Fjord artisan
Offline
Fjord artisan
S
Joined: Aug 2003
Posts: 314
I came up with a similar one but just a character shorter: /^<[\Q $prefix \E]? $+ $1> ./i

Edit: pretty much the same since you used the extra +

Last edited by Sigh; 18/10/05 11:05 AM.
Re: $iif within $regex #133244 18/10/05 12:42 PM
Joined: Feb 2004
Posts: 2,019
FiberOPtics Offline
Hoopy frood
Offline
Hoopy frood
Joined: Feb 2004
Posts: 2,019
Using the regexes already presented here:

; $fnick(<channel>,<nick>)

alias fnick return $fline($1,/^<[\Q $prefix \E]? $+ $$2> ./i,0,2)

; Example: //echo -a whoami wrote $fnick(#mirc,whoami) lines

To anyone trying out this code: note that it is tailored for whoami, as he doesn't use a timestamp, and the regex is not incorporating for it neither. Moreover, if you use a theme of some sort that displays the nick differently, obviously it won't work. It would have to be tailored exactly to fit your specific needs.


Gone.
Re: $iif within $regex #133245 18/10/05 01:04 PM
Joined: Jul 2005
Posts: 56
W
whoami Offline OP
Babel fish
OP Offline
Babel fish
W
Joined: Jul 2005
Posts: 56
I've used this. so what do u think ppl:
/^\S{0,2}(?i) $+ $1 $+ >\s.+/

am new in regular expression but Sigh's tutorials helps me alot smirk
oh btw who can send me some regex challanges so i can imporve my reggy skills

Re: $iif within $regex #133246 18/10/05 01:08 PM
Joined: Jul 2005
Posts: 56
W
whoami Offline OP
Babel fish
OP Offline
Babel fish
W
Joined: Jul 2005
Posts: 56
by the way ppl i just wants to know somethin' that i counldnt found in every regular expression tutroials. which are the things after the slash:
$regex(test,/test/THINGSCOMESHERE)

Re: $iif within $regex #133247 18/10/05 01:12 PM
Joined: Feb 2004
Posts: 2,019
FiberOPtics Offline
Hoopy frood
Offline
Hoopy frood
Joined: Feb 2004
Posts: 2,019
Those are modifiers, which will set an option in the regex that will result in a certain effect.

I'm too lazy to list/explain all of them, so I took them from tidy_trax's Wildcards & Regular Expressions tutorial:
  • /A
    This can be used instead of putting a ^ at the start of your expression.

    //echo -a $regex(abc, /a/A) will echo '1' because the string started with 'a'
  • /g
    This makes the regular expression match all matches instead of just one.

    //echo -a $regex(aaa, /\w/g) will echo '3' because it matched all 3 as.
  • /i
    This makes the regular expression case-insensitive.

    //echo -a $regex(A, /a/i) will return '1' because it no longer cares about the case of whatever it's matching.
  • /m
    This will make ^ match the start of a newline (\n or $lf) as well as the start of a string and $ match the end of a line (\r or $cr) as well as the end of a string.

    //echo -a $regex($crlf, /^$/m) will echo '1' because when the /m modifier is used ^ will match a linefeed and $ will match a carriage return.
  • /s
    This means that '.' will match any character, including newlines.

    //echo -a $regex($lf, /./s) will echo '1' because '.' now matches newlines too.
  • /S
    This will strip control codes from the string before performing a match.

    //echo -a $regex(04a, /./gS) will echo '1' because after stripping "04" from the string it only found one character.
  • /U
    This reverses the behaviour of greediness (see the "greediness" section)

    //echo -a $regex(1234, /\d+/U) will match '1' the + quantifier is no longer greedy.
  • /x
    This will ignore all spaces from your pattern except for those between \Q and \E or { and }, it also allows you to enclose comments within # and # in your expression.

    //echo -a $regex(ab, /^a #this is a comment# b$/x) will echo '1' as the /x modifier removes all spaces from your pattern so it becomes equivalent to /^ab$/
  • /X
    This will return 0 if you use \ that doesn't have a special meaning.

    //echo -a $regex(\y, /\y/X) will echo '0' as \y has no special meaning.


Gone.
Re: $iif within $regex #133248 18/10/05 03:16 PM
Joined: Jul 2005
Posts: 56
W
whoami Offline OP
Babel fish
OP Offline
Babel fish
W
Joined: Jul 2005
Posts: 56
special thanks to u Fop grin