mIRC Home    About    Download    Register    News    Help

Print Thread
CAPS Kicker using regular expressions #139207 12/01/06 09:09 AM
Joined: Sep 2003
Posts: 156
B
bleach Offline OP
Vogon poet
OP Offline
Vogon poet
B
Joined: Sep 2003
Posts: 156
How do I write a caps kicker by using regex?
Any example, please don't show me regex tutorials I can't understand anything of them.. confused

Re: CAPS Kicker using regular expressions #139208 12/01/06 09:20 AM
Joined: Feb 2004
Posts: 2,019
FiberOPtics Offline
Hoopy frood
Offline
Hoopy frood
Joined: Feb 2004
Posts: 2,019
This has been done before on these boards, do a Search for +caps +regex, expand to 5 years, put forum to "Scripts & Popups"


Gone.
Re: CAPS Kicker using regular expressions #139209 12/01/06 05:13 PM
Joined: Aug 2005
Posts: 525
S
schaefer31 Offline
Fjord artisan
Offline
Fjord artisan
S
Joined: Aug 2005
Posts: 525
Take a look at this thread: http://forums.mirc.com/s...true#Post143952

Re: CAPS Kicker using regular expressions #139210 12/01/06 07:24 PM
Joined: Jan 2006
Posts: 64
S
SoundreameR Offline
Babel fish
Offline
Babel fish
S
Joined: Jan 2006
Posts: 64
Why not use $upper() ?

Re: CAPS Kicker using regular expressions #139211 12/01/06 09:34 PM
Joined: Aug 2005
Posts: 525
S
schaefer31 Offline
Fjord artisan
Offline
Fjord artisan
S
Joined: Aug 2005
Posts: 525
$upper() will transform text to uppercase. It's not meant as a way to detect uppercase text.

For example:

//echo -a $upper(soMe tEXt) - This will result in "SOME TEXT"

Re: CAPS Kicker using regular expressions #139212 13/01/06 04:28 AM
Joined: Jan 2005
Posts: 192
Brax Offline
Vogon poet
Offline
Vogon poet
Joined: Jan 2005
Posts: 192
isupper

if ($1- isupper)

Maybe you meant that?


echo -a $signature
Re: CAPS Kicker using regular expressions #139213 13/01/06 04:30 AM
Joined: Feb 2004
Posts: 2,019
FiberOPtics Offline
Hoopy frood
Offline
Hoopy frood
Joined: Feb 2004
Posts: 2,019
//echo -a $isupper(.)
//if (. isupper) echo -a upper case

Not all that useful in other words.


Gone.
Re: CAPS Kicker using regular expressions #139214 13/01/06 04:45 AM
Joined: Jan 2005
Posts: 192
Brax Offline
Vogon poet
Offline
Vogon poet
Joined: Jan 2005
Posts: 192
Well then there is 'isalpha' as well

if ($1- isupper) && ($1- isalpha)

blush


echo -a $signature
Re: CAPS Kicker using regular expressions #139215 13/01/06 04:53 AM
Joined: Feb 2004
Posts: 2,019
FiberOPtics Offline
Hoopy frood
Offline
Hoopy frood
Joined: Feb 2004
Posts: 2,019
//var %a = AAAAAaAAAAAAAA | if (%a isupper) && (%a isalpha) echo caps detected
//var %a = AAAAA.AAAAAAAA | if (%a isupper) && (%a isalpha) echo caps detected

--> neither of those match.


Using regex for something like this makes sense, and it's easy to implement:

//var %a = AAAAA.AAAAAAAA | if ($regex(%a,/[A-Z]/g)) echo -a $v1 caps detected

But anyway, schaefer already gave a link to a thread that deals with this stuff in a good manner, so there's no need for us to go on. The point is that just using isupper or isalpha isn't going to cut it, it will require more code like looping through the word to find out how many upper case alpha chars there are, but since you can do the same with a simple regex without looping, I think it's obvious what we will prefer here.


Gone.
Re: CAPS Kicker using regular expressions #139216 13/01/06 07:19 AM
Joined: Oct 2004
Posts: 72
C
captain_comic Offline
Babel fish
Offline
Babel fish
C
Joined: Oct 2004
Posts: 72
Another trick is removing all capitals by using $removecs and then comparing the length of the original input to what is left over, but this includes numbers, punctuation and color codes. If you only want to look at alphabetic characters you should use $regex.

Re: CAPS Kicker using regular expressions #139217 14/01/06 08:58 PM
Joined: Feb 2004
Posts: 2,019
FiberOPtics Offline
Hoopy frood
Offline
Hoopy frood
Joined: Feb 2004
Posts: 2,019
And how would that be better than using a simple small regex? The code would be 10x as long, as you would need to hardcode 26 capital letters in the $removecs... and then you haven't even done the comparison yet. And then there's still the issue of digits, punctuation etc....

I can't think of one good reason why you would reply to me with that post.


Gone.
Re: CAPS Kicker using regular expressions #139218 22/01/06 10:53 AM
Joined: Oct 2004
Posts: 72
C
captain_comic Offline
Babel fish
Offline
Babel fish
C
Joined: Oct 2004
Posts: 72
Did I say it was better? I only said that $removecs provides another solution. There are many ways for scripters that lead to Rome. And you are right that $removecs doesn' t count for punctuation and digits. If you want to kick somebody who uses too much CAPS he would be kicked earlier with $regex than with $removecs, so it depends on what you want. And yes, I know that can be done easily with $regex too. By the way, the code is 2 times as long. Another thing: you use $1 in your $regex, that should be $1-. The question was: "when i type //echo -s $caps(BLA BLA) it does not return 100% when there is a space ? any idea how to fix it?"

Last edited by captain_comic; 22/01/06 10:57 AM.
Re: CAPS Kicker using regular expressions #139219 22/01/06 11:37 AM
Joined: Feb 2004
Posts: 2,019
FiberOPtics Offline
Hoopy frood
Offline
Hoopy frood
Joined: Feb 2004
Posts: 2,019
I am not using $1 anywhere in this thread, but I suppose you are referring to that thread that was linked to here where I posted a solution using regex.

You're wrong.

In mIRC, identifiers are delimited by commas not by spaces, so $1 contains the entire string passed.

alias test {
echo -a 1 = $1
echo -a 2 = $2
}

//!.echo -q $test(this is the first parameter, this is the second)

In other words, passing $1- to test like $test($1-) means there is only 1 parameter (no commas), which means inside the test alias the entire string is contained in $1.

Whether someone will get kicked quicker or not with the regex all depends on how the regex was created, so your argument holds no water. I didn't make any tailored function to help the original requester with his problem, the regexes that I did use merely pointed out something to Brax, they were not "final" solutions of any kind.

Think twice before trying to correct me.


Gone.
Re: CAPS Kicker using regular expressions #139220 22/01/06 12:55 PM
Joined: Oct 2004
Posts: 72
C
captain_comic Offline
Babel fish
Offline
Babel fish
C
Joined: Oct 2004
Posts: 72
Quote:
Think twice before trying to correct me.

OMG you're so arrogant, I'll ignore you from now on, so you don't have to answer this also.

Re: CAPS Kicker using regular expressions #139221 22/01/06 01:39 PM
Joined: Feb 2004
Posts: 2,019
FiberOPtics Offline
Hoopy frood
Offline
Hoopy frood
Joined: Feb 2004
Posts: 2,019
Oh, you are surprised that when you make incorrect statements about someone, that they will respond with "think twice before trying to correct me"? Do you think I am going to say that you're right, when you're in fact wrong? Did you expect me to just let you say that I'm wrong, when I'm right? Haha.

I'm 100% right about that $1 statement, you are 100% wrong about it, so you did in fact need to think twice before making that post, as it would have saved you from the embarrassement.

I'm arrogant? I'm not the one making false claims and not acknowledging that I'm wrong even after being pointed about it. Think about how arrogant that is. A modest person would admit being wrong, possibly appologize for making the false claim, and carry on.


Gone.
Re: CAPS Kicker using regular expressions #139222 22/01/06 03:53 PM
Joined: Oct 2004
Posts: 72
C
captain_comic Offline
Babel fish
Offline
Babel fish
C
Joined: Oct 2004
Posts: 72
Ok, I will try once. If I am wrong (I was) then you can correct me. I like to learn and yes I admit you know a lot. But it is the way you correct people, the words you choose, like "Think twice ...". A good teacher never insults his pupils, otherwise they will ignore him. Thank you.

Re: CAPS Kicker using regular expressions #139223 22/01/06 10:07 PM
Joined: Feb 2004
Posts: 2,019
FiberOPtics Offline
Hoopy frood
Offline
Hoopy frood
Joined: Feb 2004
Posts: 2,019
Well, I understand your position, but there is one thing you forgot to take into account:

  • I'm not a teacher, and you're not a pupil.
In other words, this is a case where one helper (you) tries to correct another helper (me).

If you look at it in that perspective, then me saying you should think twice before trying to correct me isn't that weird at all.

I suppose it's clear by now: I do not appreciate people telling me what I supposedly do wrong when I know I'm right, and I will keep saying what I've said (think twice before...) for as long as anyone (not you per sť) feels the urge to try to correct me in such circumstances.

There's not one strand of hair on my head that would even consider trying to correct someone on a certain aspect, when I know that they are multiple times better than me in that field. At best, I would formulate it in a careful question in the trend of: "Shouldn't that be... ?", which, applied to this situation, would be something like: "I might be wrong but shouldn't you specify $1- instead of $1 in the identifier"? And I would have responded with "No, because...", and we wouldn't even be having this conversation.

So, where you thought I was arrogant in my reply, I already thought you were arrogant before my reply, for not considering the fact that you might be wrong (for which the odds were high), and not having the subtlety to formulate your claim in a more "question"-like way, when addressing someone that is far more experienced than you are.

Looking back at it, I didn't even do any sort of name calling, whereas you are the one that personally attacked me by saying "OMG you're so arrogant". You didn't take the time to look at it from my point of view.

Anyway, you know how I feel, I know how you feel, so as far as I'm concerned this case is closed.


Gone.