Using $ to match the end of the input gives a zero-length match everywhere, but there is no evidence of matching with WebKit:
function showBug() {
Result = "the end.".replace( /(end\.)([\s]|$)?/img, makeChange );
return;
}
function makeChange() {
for ( var i = 0; i < arguments.length; i += 1 ) {
document.write( "arg" + i + " -->" + arguments[ i ] + "<--" + "<BR>" );
}
}
gives
arg0
arg1
arg2
arg3
arg4
for AppleWebKit/534.55.3 (KHTML, like Gecko) Version/5.1.5 Safari/534.55.3, also for AppleWebKit/535.19 (KHTML, like Gecko) Chrome/18.0.1025.162 Safari/535.19.
Opera ( Presto/2.10.229 Version/11.62), FF ( Gecko/20100101 Firefox/10.0.2) and IE ( MSIE 8.0; Trident/4.0) give
arg0
arg1
arg2
arg3
arg4
which means that I can determine the match at $ 2 (this actually means interpreting the endpoint on the url as it is not part of the url). I am currently adding a trailing space for WebKit and renting it, but I am wondering if anyone has a better solution and can confirm that I should raise this as an error.
source
share