Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Web and WebWorks Development

Reply
Highlighted
Developer
Posts: 27
Registered: ‎07-24-2009
My Device: Not Specified

Regex difference compared to other browsers

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.

Developer
Posts: 27
Registered: ‎07-24-2009
My Device: Not Specified

Re: Regex difference compared to other browsers

What's strange is blackberry knows to this should output '$2b'

 

alert('ab'.replace(/a|(\s)$/, '$2'));