mIRC Home    About    Download    Register    News    Help

Print Thread
#183976 24/08/07 04:56 AM
Joined: Feb 2005
Posts: 342
R
Rand Offline OP
Fjord artisan
OP Offline
Fjord artisan
R
Joined: Feb 2005
Posts: 342
Code:
alias hehtest { 
  var %r = /^[0-9]{1,3}(?:\.\d{1,3}){3}$/
  var %t = 17.17.17.17
  ; Using variables, the first test functions as expected, echoing a 1.
  echo -a First test: $regex(%t,%r)

  ; No variable useage, the exact same plain text as the variables, but fails
  ; and echos a 0.  
  ; Also, you can not specify a <name> parameter when you do this..
  echo -a Second test: $regex(17.17.17.17,/^[0-9]{1,3}(?:\.\d{1,3}){3}$/)

  ; Almost the split image of above, but we encompas it in (),
  ; and doing so will echo a 1.
  echo -a Third test: $regex(17.17.17.17,/^([0-9]{1,3}(?:\.\d{1,3}){3})$/)

  ; Now, just going off of assumptions here. I'm assuming it's the "," in {1,3}
  ; That is causing it to not work. As this fails the test too:
  echo -a Alternative: $regex(17.17.17.17,/^[0-9.]{1,}$/)

  ; And this one passes:
  echo -a Next Alternative: $regex(17.17.17.17,/^[0-9.]{11}$/)
}


My guess is that the "," (ie: {1,}) is breaking the function unless you enclose it in (). When you do use the {1,} it also makes it so you can no longer use the optional name parameter in the $regex()

Edit: Yeah, I'm assuming this might be a known bug/problem, but I've got a cold and I'm tired, so didn't bother to search before I posted. So no need to point that out to me.

Last edited by Rand; 24/08/07 05:09 AM.
Rand #183994 24/08/07 10:30 AM
Joined: Sep 2005
Posts: 2,881
H
Hoopy frood
Offline
Hoopy frood
H
Joined: Sep 2005
Posts: 2,881
It's not a bug. The comma separates arguments in an identifier, so you should set a variable or use (?: ... ) like you've displayed there.

Rand #184006 24/08/07 01:16 PM
Joined: Mar 2006
Posts: 395
T
Pan-dimensional mouse
Offline
Pan-dimensional mouse
T
Joined: Mar 2006
Posts: 395
instead of using a comma in {1,3} for example,
use {1 $+ $chr(44) $+ 3}

It can be a pain sometimes, but you will get used to it....

Kinda like using a %#RoomName because it has to be scripted as $chr(37) $+ #RoomName due to variables.

Why is it like this? mIRC dosnt require everything in quotes, to which most of us prefer.

Hope this helps


[02:16] * Titanic has quit IRC (Excess Flood)
Rand #184012 24/08/07 02:43 PM
Joined: Oct 2006
Posts: 166
B
Vogon poet
Offline
Vogon poet
B
Joined: Oct 2006
Posts: 166
do what hixxy told. I save them in variables then pass them to the regex.


Kind Regards, blink
b1ink #215611 25/09/09 09:42 PM
Joined: Aug 2007
Posts: 42
L
Ameglian cow
Offline
Ameglian cow
L
Joined: Aug 2007
Posts: 42
Retarded.
Srsly.
Almost a hour tried to realize where I was wrong >_>


"Do, or do not. There is no 'try'." - Yoda ('The Empire Strikes Back')
Rand #215645 27/09/09 08:42 AM
Joined: Jul 2008
Posts: 236
S
Fjord artisan
Offline
Fjord artisan
S
Joined: Jul 2008
Posts: 236
I'm sure you've gathered by now that if you don't use commas in your regular expressions, or you set a variable to your regex, then it works as expected. This happens to the best of us, especially in such an awkward language.


Link Copied to Clipboard