mIRC Homepage

$reges question

Posted By: Canario

$reges question - 06/12/04 07:19 PM

//echo -a $regex(guest12343,/([0-9]){5}/) $regml(1)
In this case $regex returns 1 and $regml(1) the last match number (3)

//echo -a $regex(guest12343,/([0-9]){4,5}/) $regml(1)
1st question:
Why $regex returns 0 in the last example? itīs look like the 1st case only I change 5 times for 4 or 5 times.

2nd question: How I Can return the whole number and not only the last number match? (with $regml)
Posted By: Sigh

Re: $reges question - 06/12/04 07:33 PM

As usual, when you're trying to pass a comma as a character in an identifier it needs to be escaped:


Or assign the expression to a local variable:

var %r = /([0-9]){4,5}/
echo -a $regex(string,%r)

In this case though, you can just change the expression slightly to erradicate the need for a {} quantifier:

echo -a $regex(string,/(\d{4}\d?)/)

Which also answers your second question, enclosing the whole part that matches the full number in parentheses i.e. ([0-9]{4,5}) instead of ([0-9]){4,5} will make it capture the whole number rather than the first one matched
Posted By: tidy_trax

Re: $reges question - 06/12/04 07:35 PM

Both questions can be answered with the same answer smile
Put the {4,5} inside the ().

//echo -a $regex(guest12345,/(\d{4,5})/) $regml(1)

Just in case you were wondering, \d is the same as [0-9].
Posted By: tidy_trax

Re: $reges question - 06/12/04 07:38 PM

For some reason {N,N} doesn't need to be escaped.
Posted By: Sigh

Re: $reges question - 06/12/04 07:50 PM

Not in all cases, just whenever the comma is enclosed in parentheses, (\d{4,5}) not (\d){4,5}, works this way with all identifiers. Check out $remove(a(,b,)c,(,b,))
Posted By: tidy_trax

Re: $reges question - 06/12/04 07:55 PM

Oh, never knew about that, handy little feature. Thanks. smile
Posted By: Canario

Re: $reges question - 06/12/04 09:59 PM

Thanks for the good explanation smile
© 2022 mIRC Discussion Forums