mIRC Homepage

$iif within $regex

Posted By: whoami

$iif within $regex - 18/10/05 10:50 AM

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.
Posted By: hixxy

Re: $iif within $regex - 18/10/05 11:00 AM

Try this:

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

Re: $iif within $regex - 18/10/05 11:04 AM

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 +
Posted By: FiberOPtics

Re: $iif within $regex - 18/10/05 12:42 PM

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.
Posted By: whoami

Re: $iif within $regex - 18/10/05 01:04 PM

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
Posted By: whoami

Re: $iif within $regex - 18/10/05 01:08 PM

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)
Posted By: FiberOPtics

Re: $iif within $regex - 18/10/05 01:12 PM

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.
Posted By: whoami

Re: $iif within $regex - 18/10/05 03:16 PM

special thanks to u Fop grin
© 2022 mIRC Discussion Forums