Regular Expressions in Server Side JS Poorly implemented

So far, I’ve found two bugs:

Passing a function as the second parameter of String.replace doesn’t work:

var object = { firstName: ‘Tommy’, lastName: ‘Valand’ };

var template = ‘{lastName}, {firstName}’

template.replace( /{(\w+)}/g, function( item, key ){

return object[key] || '';

});

The result should be: “Valand, Tommy”

The result is: “,”

String.replace in Server Side JS does not accept a function as the second parameter.

String.match with global modifier:

var template = ‘{lastName}, {firstName}’;

template.match( /{(\w+)}/g );

The result should be: [“{lastName}”, “{firstName}”]

The result is: [“{lastName}”, “lastName”]

String.match in Server Side JS ignores the global modifier.

The worst part… The above JavaScript code works with Client JavaScript in Notes, which I believe was introduced in Notes 5.0… :\

Subject: some answers

The inability to use a function as a parameter in replace in a recorded SPR and we hope to fix it in the 8.5 timeframe.Now, server side JS uses the Java regular expression engine which might explain some differences between in the syntax. I guess the differences are minor, but this is what you’re facing here.