RegExp a|ab bug

A Listing of Confirmed Scripting Bugs and Anomalies - Open to all but only moderators can post

Moderators: xbytor, Kukurykus, Tom

Andrew

RegExp a|ab bug

Post by Andrew »

Between Xbytor and myself we have established that there is a bug in Adobe Javascript's treatement of RegExp OR / '|'.

In normal (non-Adobe) Javascript, the following will find the position of the search characters:

Code: Select allvar str = 'abcd';
var re = /(b|bc)d/;
alert(str.search(re)); // returns 1

With Adobe Javascript the test returns -1 (not found).

Adobe Javascript would appear to not explore the possibilities of the second IF condition when the first IF condition has returned an initial TRUE ie:

If the 'b' condition is true > test if the full expression is true, but if the full expression is false do not then test if the 'bc' condition might be true.

With Adobe JS you can get around the problem with any of:

Code: Select allre = /(bc|b)d/;
re = /(bd|bcd)/;
re = /bc?d/;

For more discussion go here:

bb/viewtopic.php?p=1744#1744

Andrew