mIRC Homepage
Posted By: ScatMan regex - 25/07/03 10:12 PM
i don't understand why (a+)* matches 33 times in "aaaa" ?
Posted By: codemastr Re: regex - 25/07/03 10:19 PM
Umm, what are you talking about?

//echo -a $regex(aaaa,/(a+)*/g)
result:
2

Thats a big difference from 33.
Posted By: ScatMan Re: regex - 25/07/03 10:23 PM
i dunno that's what man.txt says, i meant that it trying to match in 33 posibilities.
Posted By: ScatMan Re: regex - 26/07/03 08:52 AM
??
Posted By: LocutusofBorg Re: regex - 26/07/03 09:09 AM
Learn regular expressions properly. There's plenty of tutorials available on the web. Regular expressions atre NOT something specific to mIRC, khaled just gave mIRC the ability to use them.
Posted By: ScatMan Re: regex - 26/07/03 09:50 AM
please stop replying to me!!


Posted By: LocutusofBorg Re: regex - 26/07/03 10:29 AM
Then stop asking these stupid questions.
Posted By: ScatMan Re: regex - 26/07/03 12:55 PM
if u don't know the answer it doesn't mean it's a stupid question

Posted By: LocutusofBorg Re: regex - 26/07/03 01:34 PM
You are asking someone here to explain to you how regular expressions work. Not only is that not a mIRC scripting question, as regular expressions existed long before mIRC did, you also obviously have not taken the time to read toturials that can be found on the internet about regular expressions, of which there are plenty, nor have you searched this forum, as there are numerous references about using regular expressions. If I recall, Hammer made reference to a log of a class he gave on regular expressions not too long ago. If I'm wrong, follow this link to get there: http://helpdesk.zaz.net/channel/classes/basic-regex.txt .
Posted By: ScatMan Re: regex - 26/07/03 01:46 PM
actually i already know the basics about regex and i took the time to read several tutorials, but sometimes i don't understand something that i read and i ask it here and get help.
now shut up and stop replying with your stupid posts.






Posted By: Watchdog Re: regex - 26/07/03 02:47 PM
It's not possible or conventional to choose who answers a question. The question should be answered by the people that best know the answer to that question. That seems to be the case here.
Posted By: codemastr Re: regex - 26/07/03 03:31 PM
You already got your answer, it does NOT match 33 times. If you don't like that answer, well then you've got a problem, because that IS the answer.
Posted By: ScatMan Re: regex - 26/07/03 04:15 PM
not match 33 times, try 33 posibilities to match
from man.txt:
"Beware of patterns that contain nested indefinite repeats.
These can take a long time to run when applied to a string
that does not match. Consider the pattern fragment

(a+)*

This can match "aaaa" in 33 different ways"
Posted By: ParaBrat Re: regex - 26/07/03 05:21 PM
You cannot dictate who will answer you. I strongly suggest you reboot your attitude if you expect anyone to help you.
Posted By: ScatMan Re: regex - 26/07/03 05:27 PM
locotusofborg doesn't even trying to help me
Posted By: codemastr Re: regex - 26/07/03 05:35 PM
Do you understand the internals of regex matching? Regex is a very complex system, for me to explain to you why that happens accurately would require you to know a lot about regex. To put it this way, I'm currently studying the algorithm used by one regex library, and it is aboyt 70 pages of text, and that just describes the algorithm, not the entire regex system. It's not something I can just say "here is why it does that" It is a very complex process to explain.
Posted By: pheonix Re: regex - 26/07/03 06:00 PM
coz your an ignorant fool.
Posted By: ScatMan Re: regex - 26/07/03 06:01 PM
i didn't say i don't know regex, i just don't understand it when it's nested quantifiers like (a+)*

Posted By: codemastr Re: regex - 26/07/03 06:37 PM
How about you read what I said? I didn't say you don't know regex, I said you don't know the INTERNALS of it. But seeing as how you refuse to listen, read http://perl.plover.com/Regex and then you might have enough understanding to figure out why that happens.
Posted By: LocutusofBorg Re: regex - 26/07/03 07:53 PM
Of course I didn't go into it any deeper. Your question, and the reply you originally gave codemaster told me you weren't gonna grasp any answers. It would be like giving a 5 yr old who just learned the alphabet the collected works of Shakespeare....
Posted By: tomalak16 Re: regex - 26/07/03 08:33 PM
Quote:
This can match "aaaa" in 33 different ways"


That would be because there are 33 combinations of the configuration (a+)* in that string. Consider..

(a)* (aa)* (aaa)* (aaaa)*

and those first three can match anywhere within the string.
Quite a number of possibilities.

You just wouldn't notice the difference because the only difference is the position the individual characters reside in memory. To the human eye, they are all "a".
Posted By: tomalak16 Re: regex - 26/07/03 08:47 PM
(a+)*

can become any of:

(a)*
(aa)*
(aaa)*
(aaaa)*

and that can become (i have the whole string in black, the part the regex matches in red):

1. aaaa
2. aaaa
3. aaaa
4. aaaa

5. aaaa
6. aaaa
7. aaaa

8. aaaa
9. aaaa

10. aaaa

And that's just with the (a+) part.

If you add * to the equation... that's most of those above, another 2 or 3 or 4 times. We've already got 10 combinations.

Here is the extended version:

1a) aaaa
b) aaaa
c) aaaa
d) aaaa
2a) aaaa
b) aaaa
c) aaaa
3a) aaaa
b) aaaa

etc..
Some of these may look a lot alike to you, but in terms of processing and how they are matched, there are 33 ways to come up with that match.
Posted By: ScatMan Re: regex - 26/07/03 10:12 PM
i dunno.. i will try to read the tutorial codemastr gave
© mIRC Discussion Forums