mIRC Home    About    Download    Register    News    Help

Print Thread
Need some help #187817 13/10/07 12:00 PM
Joined: Jun 2006
Posts: 79
B
BanJirian Offline OP
Babel fish
OP Offline
Babel fish
B
Joined: Jun 2006
Posts: 79
Code:
 
    if ($regex($3-,/[[:cntrl:]]/g) > 49) { .signal -n d $1-2 codes } 
    if ($regex($3-,/[[:upper:]]/g) > 49) { .signal -n d $1-2 caps } 
    if ($regex($3-,/\d/g) > 49) { .signal -n d $1-2 number }
    if ($regex($3-,/[[:punct:]]/g) > 49) { .signal -n d $1-2 symbol } 
    if ($regex($3-,/[ $chr(174) ]/g) > 49) { .signal -n d $1-2 ascii } 
    if ($regex($3-,/[ $chr(160) ]/g) > 49) { .signal -n d $1-2 blur } 
    if ($regex($3-,/./g) > 199) { .signal -n d $1-2 lenght }
    if ($regex($3-,/(#|http://|www.|.com|.net|.org)/i)) { .signal -n d $1-2 advertise }
    if ($regex($3-,/\b(fucck|sck|shyit|btch)\b/i)) { .signal -n d $1-2 swear }


Can somebody give me diff way besides using $regex(with example). I need fastest way rather than using $regex. This is just a simple comparison so think besides using $regex there is other best way and hope somebody could gimme the example.

Re: Need some help [Re: BanJirian] #187925 15/10/07 05:27 AM
Joined: Aug 2005
Posts: 1,052
L
Lpfix5 Offline
Hoopy frood
Offline
Hoopy frood
L
Joined: Aug 2005
Posts: 1,052
Originally Posted By: BanJirian
Code:
 
    if ($regex($3-,/[[:cntrl:]]/g) > 49) { .signal -n d $1-2 codes } 
    if ($regex($3-,/[[:upper:]]/g) > 49) { .signal -n d $1-2 caps } 
    if ($regex($3-,/\d/g) > 49) { .signal -n d $1-2 number }
    if ($regex($3-,/[[:punct:]]/g) > 49) { .signal -n d $1-2 symbol } 
    if ($regex($3-,/[ $chr(174) ]/g) > 49) { .signal -n d $1-2 ascii } 
    if ($regex($3-,/[ $chr(160) ]/g) > 49) { .signal -n d $1-2 blur } 
    if ($regex($3-,/./g) > 199) { .signal -n d $1-2 lenght }
    if ($regex($3-,/(#|http://|www.|.com|.net|.org)/i)) { .signal -n d $1-2 advertise }
    if ($regex($3-,/\b(fucck|sck|shyit|btch)\b/i)) { .signal -n d $1-2 swear }


Can somebody give me diff way besides using $regex(with example). I need fastest way rather than using $regex. This is just a simple comparison so think besides using $regex there is other best way and hope somebody could gimme the example.


I think regex is the best here.. else I think this is another way of doing it.

Code:
  if ($len($3-) > 49) { 
    if ($isupper($3-) == $true) { .signal -n d $1-2 caps }
    if ($3- isnum) { .signal -n d $1-2 Number }
    if ($chr(174) isin $3-) { .signal -n d $1-2 ascii }
    if ($chr(16) isin $3-) { .signal -n d $1-2 blur }
  }
  if ($len($3-) > 199) { .signal -n d $1-2 length }
  if (fucck isin $3-) || (sck isin $3-) || (shyit isin $3-) || (btch isin $3-) { .signal -n d $1-2 swear }
  if ($chr(35) isin $3-) || (www. isin $3-) || (.com isin $3-) || (.net isin $3-) || (.org isin $3-) { .signal -n d $1-2 advertise }


Code:
if $reality > $fiction { set %sanity Sane }
Else { echo -a *voices* }
Re: Need some help [Re: Lpfix5] #187928 15/10/07 08:09 AM
Joined: Dec 2002
Posts: 503
B
Bekar Offline
Fjord artisan
Offline
Fjord artisan
B
Joined: Dec 2002
Posts: 503
Lpfix5 got some of 'em..

But here's my opinion..

Code:
if ($regex($3-,/[[:cntrl:]]/g) > 49) { .signal -n d $1-2 codes }
if ($regex($3-,/[[:upper:]]/g) > 49) { .signal -n d $1-2 caps }
if ($regex($3-,/\d/g) > 49) { .signal -n d $1-2 number }
if ($regex($3-,/[[:punct:]]/g) > 49) { .signal -n d $1-2 symbol } 
if ($regex($3-,/[ $chr(174) ]/g) > 49) { .signal -n d $1-2 ascii } 
if ($regex($3-,/[ $chr(160) ]/g) > 49) { .signal -n d $1-2 blur }

As good as it'll probably get. To do this sort of character-counting using any other method involves looping 'n stuff.

Code:
if ($regex($3-,/./g) > 199) { .signal -n d $1-2 lenght }

Lpfix5 has this one right, just a plain $len().

Code:
if ($regex($3-,/(#|http://|www.|.com|.net|.org)/i)) { .signal -n d $1-2 advertise }

The expression could be tightened up a bit, but it's the easiest way.

Code:
if ($regex($3-,/\b(fucck|sck|shyit|btch)\b/i)) { .signal -n d $1-2 swear }

This is the quicked/easiest way for a static list of words. If you want a dynamic list of words, there are other ways, but doing the 'isin' method is nowhere near as efficient in my mind (also nowhere near as accurate. 'isin' will match partial words. The \b(pattern|pattern)\b method is much more accurate.).

Re: Need some help [Re: Bekar] #187934 15/10/07 10:54 AM
Joined: Jun 2006
Posts: 79
B
BanJirian Offline OP
Babel fish
OP Offline
Babel fish
B
Joined: Jun 2006
Posts: 79
what about punctuation and cntrl codes ?

Re: Need some help [Re: BanJirian] #187942 15/10/07 12:27 PM
Joined: Dec 2002
Posts: 503
B
Bekar Offline
Fjord artisan
Offline
Fjord artisan
B
Joined: Dec 2002
Posts: 503
The looking for excess of each is best handled like the existing $regex() in my opinion. To count them with a while loop would be wasteful.

Now that I think about it a bit further, you should probably include the initial $len($3-) that Lpfix5 had there, so as not to bother doing a check if the string is less than 49 characters (as you're min. count is 49, it will never match a string that's 20 characters long. to just skip the checks when they aren't needed basically).

Re: Need some help [Re: Bekar] #187950 15/10/07 04:21 PM
Joined: Aug 2005
Posts: 1,052
L
Lpfix5 Offline
Hoopy frood
Offline
Hoopy frood
L
Joined: Aug 2005
Posts: 1,052
In theory im not sure what he needed, because to me it would mean that $3- would be alot of ascii or numbers or whatever... and the length would be greater then 49 that's why I included the length check as standard procedure. I just went by what the regex functions were.

as far as CTRL codes

Code:
if ( isin $3-) || ( isin $3-) || (	 isin $3-) || ( isin $3-) || ( isin $3-) { .signal -n d $1-2 Codes }


this checks for color, bold, italic, highlight and underline


Code:
if $reality > $fiction { set %sanity Sane }
Else { echo -a *voices* }
Re: Need some help [Re: Lpfix5] #187964 15/10/07 09:24 PM
Joined: Dec 2002
Posts: 503
B
Bekar Offline
Fjord artisan
Offline
Fjord artisan
B
Joined: Dec 2002
Posts: 503
Yeah, but it doesn't count how many of them have been used.

Re: Need some help [Re: BanJirian] #188037 16/10/07 06:26 PM
Joined: Jun 2006
Posts: 508
D
deegee Offline
Fjord artisan
Offline
Fjord artisan
D
Joined: Jun 2006
Posts: 508
One simple way to speed it up is to use elseif so if a match is made the rest of the if's are skipped.

Code:
    if ($regex($3-,/\b(fucck|sck|shyit|btch)\b/Si)) { .signal -n d $1-2 swear }
    elseif ($regex($3-,/(#|http://|www.|.com|.net|.org)/Si)) { .signal -n d $1-2 advertise }

    elseif ($len($3-) < 50) { return }
    elseif ($v1 > 199) { .signal -n d $1-2 lenght } | ; <<- lenght? or length?
    elseif ($regex($3-,/[[:cntrl:]]/g) > 49) { .signal -n d $1-2 codes } 
    elseif ($regex($3-,/[[:upper:]]/g) > 49) { .signal -n d $1-2 caps } 
    elseif ($regex($3-,/\d/g) > 49) { .signal -n d $1-2 number }
    elseif ($regex($3-,/[[:punct:]]/g) > 49) { .signal -n d $1-2 symbol } 
    elseif ($regex($3-,/[ $chr(174) ]/g) > 49) { .signal -n d $1-2 ascii } 
    elseif ($regex($3-,/[ $chr(160) ]/g) > 49) { .signal -n d $1-2 blur } 


You can also try $count() to see if it works out cheaper than any of the RE's. (example: $count($3-,0,1,2,3,4,5,6,7,8,9) or $count($3-,,,,,))

Re: Need some help [Re: Lpfix5] #188039 16/10/07 06:29 PM
Joined: Jun 2006
Posts: 508
D
deegee Offline
Fjord artisan
Offline
Fjord artisan
D
Joined: Jun 2006
Posts: 508
Italic? wink
(BTW That's a tab that you have in that comparison)