Regular expression bugs!!! - 17/06/03 08:26 PM
Here's something cut and pasted from a script I was working on...
RANT: Did I mention that mirc can't [bleep] parse regular expressions correctly!?!?!?!?!
Try - Result
\) - if fails to match )'s...
(\)) - fails
[)] - fails
([)]) - fails as well
(\(\)) - works to find ()'s
(\() - fails to even be valid code at runtime!
(\)\() - works to find )('s
In fact any attempt to search for any unequal number of open and close parens either fails to compile(!) or fails to find anything!!!!!!! GRRRRR.... took a while to diagnose this one as it was HUGE regex when I started... I'm guessing its a parsing error in the actual script compiler/interpretter and not a regular expression error.
This is using 6.03. I'd also like to point out that while documentation of regular expressions is missing it WOULD have been nice to point to which model was being used as not all of them have the same features... Compare emacs to perl for example. A list of valid identifiers and post operators would eliminate a lot of trial and error...
OH... and while I'm at it...
Mirc in my opinion mishandles matched strings enclosed in parethesis for reference with the $regml function! I'm sure this is a sideffect of the way mirc handles arguments and again not a regex issue... but anyway its wrong... here's why.
Goto perl and do something like this:
($a, $b, $c) = teststring =~ /(test)st(d)?(ring)/;
printf("%s - %s - %s\n", $a, $b, $c);
Returns: test - - ring
Now do something similiar in mirc:
$regex(TEST, teststring, /(test)st(d)?(ring)/ )
/echo $regml(TEST, 1) - $regml(TEST, 2) - $regml(TEST, 3)
Returns: test - ring -
Thus any complex regular expression in which one wishes to test what fields match is almost USELESS because the matched positional information is completely lost in mirc... You would end up having to retest submatches to figure out what the heck really matched. Perl is far far more powerful...
-Yil
RANT: Did I mention that mirc can't [bleep] parse regular expressions correctly!?!?!?!?!
Try - Result
\) - if fails to match )'s...
(\)) - fails
[)] - fails
([)]) - fails as well
(\(\)) - works to find ()'s
(\() - fails to even be valid code at runtime!
(\)\() - works to find )('s
In fact any attempt to search for any unequal number of open and close parens either fails to compile(!) or fails to find anything!!!!!!! GRRRRR.... took a while to diagnose this one as it was HUGE regex when I started... I'm guessing its a parsing error in the actual script compiler/interpretter and not a regular expression error.
This is using 6.03. I'd also like to point out that while documentation of regular expressions is missing it WOULD have been nice to point to which model was being used as not all of them have the same features... Compare emacs to perl for example. A list of valid identifiers and post operators would eliminate a lot of trial and error...
OH... and while I'm at it...
Mirc in my opinion mishandles matched strings enclosed in parethesis for reference with the $regml function! I'm sure this is a sideffect of the way mirc handles arguments and again not a regex issue... but anyway its wrong... here's why.
Goto perl and do something like this:
($a, $b, $c) = teststring =~ /(test)st(d)?(ring)/;
printf("%s - %s - %s\n", $a, $b, $c);
Returns: test - - ring
Now do something similiar in mirc:
$regex(TEST, teststring, /(test)st(d)?(ring)/ )
/echo $regml(TEST, 1) - $regml(TEST, 2) - $regml(TEST, 3)
Returns: test - ring -
Thus any complex regular expression in which one wishes to test what fields match is almost USELESS because the matched positional information is completely lost in mirc... You would end up having to retest submatches to figure out what the heck really matched. Perl is far far more powerful...
-Yil