mIRC Home    About    Download    Register    News    Help

Print Thread
#157929 30/08/06 01:09 PM
Joined: Feb 2005
Posts: 342
R
Rand Offline OP
Fjord artisan
OP Offline
Fjord artisan
R
Joined: Feb 2005
Posts: 342
Okay, I just realized there's a small bug in mIRC's Regex. (for all of the $reg* functions)

As an example:

(mirc code)
Code:
alias regextest {
  var %text = Just a test. Bust my test.
  echo -ag $regsubex(%text,/(?<=[^J])ust/g,usssst)
}


That will not change "Bust" to "Busssst" as it should. Inserting a space between the ^ and the J seems to "fix" the problem (it apparently just needs TWO characters in it to fix it, one character doesn't seem to make it trigger). I had almost thought, at first, that this was an error somewhere on my behalf, but I made a .pl file (perl script) and put this in it just to double check:

(perl code)
Code:
my $text = "Just a test. Bust my test.";
print "$text\n";
print "Modifying the contents of \$text\n\n";
$text =~ s/(?<=[^J])ust/usssssssst/g;
print "$text\n";


Which outputs:
Quote:
Just a test. Bust my test.
Modifying the contents of $text

Just a test. Busssssssst my test.

#157930 30/08/06 02:30 PM
Joined: Oct 2005
Posts: 1,741
G
Hoopy frood
Offline
Hoopy frood
G
Joined: Oct 2005
Posts: 1,741
I've confirmed this behavior. It looks like a problem in the code that deals with negated character classes within lookbehind structures (positive and negative). Since it works if more than one character is within the negated character class, my guess is that there may be a loop/comparison that starts one integer too high or low.

(?<=[J]) <- works
(?<![J]) <- works
(?<=[^J]) <- fails
(?<![^J]) <- fails

Here is a temp workaround:

(?<=[^JJ]) <- works

-genius_at_work

#157931 30/08/06 04:08 PM
Joined: Dec 2002
Posts: 5,465
Hoopy frood
Offline
Hoopy frood
Joined: Dec 2002
Posts: 5,465
Thanks this was due to a bug in the PCRE library. I've updated to the latest version which seems to resolve the issue.

#157932 31/08/06 03:49 AM
Joined: Feb 2005
Posts: 342
R
Rand Offline OP
Fjord artisan
OP Offline
Fjord artisan
R
Joined: Feb 2005
Posts: 342
Yep, genius_at_work, already had a work around by the time I made that post.

Khaled: Thanks, much appreciated.


Link Copied to Clipboard