Welcome to the Official BlackBerry® Support Community Forums. This is your resource to discuss support topics with your peers, and learn from each other. New to the forum? Please visit the ‘Getting Started’ link below.
inside custom component

Web and WebWorks Development

Reply
Developer
NinjaCoder
Posts: 27
Registered: 07-24-2009

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.

Please use plain text.
Developer
NinjaCoder
Posts: 27
Registered: 07-24-2009

Re: Regex difference compared to other browsers

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

 

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

 

 

Please use plain text.