mIRC Homepage

CAPS Kicker using regular expressions

Posted By: bleach

CAPS Kicker using regular expressions - 12/01/06 09:09 AM

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

Re: CAPS Kicker using regular expressions - 12/01/06 09:20 AM

This has been done before on these boards, do a Search for +caps +regex, expand to 5 years, put forum to "Scripts & Popups"
Posted By: schaefer31

Re: CAPS Kicker using regular expressions - 12/01/06 05:13 PM

Take a look at this thread: http://forums.mirc.com/s...true#Post143952
Posted By: SoundreameR

Re: CAPS Kicker using regular expressions - 12/01/06 07:24 PM

Why not use $upper() ?
Posted By: schaefer31

Re: CAPS Kicker using regular expressions - 12/01/06 09:34 PM

$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"
Posted By: Brax

Re: CAPS Kicker using regular expressions - 13/01/06 04:28 AM

isupper

if ($1- isupper)

Maybe you meant that?
Posted By: FiberOPtics

Re: CAPS Kicker using regular expressions - 13/01/06 04:30 AM

//echo -a $isupper(.)
//if (. isupper) echo -a upper case

Not all that useful in other words.
Posted By: Brax

Re: CAPS Kicker using regular expressions - 13/01/06 04:45 AM

Well then there is 'isalpha' as well

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

blush
Posted By: FiberOPtics

Re: CAPS Kicker using regular expressions - 13/01/06 04:53 AM

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

Re: CAPS Kicker using regular expressions - 13/01/06 07:19 AM

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

Re: CAPS Kicker using regular expressions - 14/01/06 08:58 PM

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

Re: CAPS Kicker using regular expressions - 22/01/06 10:53 AM

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

Re: CAPS Kicker using regular expressions - 22/01/06 11:37 AM

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

Re: CAPS Kicker using regular expressions - 22/01/06 12:55 PM

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

Re: CAPS Kicker using regular expressions - 22/01/06 01:39 PM

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

Re: CAPS Kicker using regular expressions - 22/01/06 03:53 PM

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

Re: CAPS Kicker using regular expressions - 22/01/06 10:07 PM

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.
© 2021 mIRC Discussion Forums