11-08-2009 07:31 PM
Blackberry has a difference on regex compared to other browsers:
In all browsers this alerts " b"
alert(' b'.replace(/a|(\s)$/, '$1'));
In most browsers this alerts "b" however in blackberry this is a javascript exception
alert('ab'.replace(/a|(\s)$/, '$1'));
I reproed this with the SDK 5.0 Beta 4 Emulator.
Please fix this before 5.0 ships.
I believe I could do:
alert('ab'.replace(/a|(\s)$/, function(match){ if (match == 'a') return ''; else return match}));
But it will be hard for me to track down all the $X replacement statements.
11-08-2009 07:39 PM
What's strange is blackberry knows to this should output '$2b'
alert('ab'.replace(/a|(\s)$/, '$2'));