If you make use of [Underscore.js](http://www.underscorejs.org) and [node's built in path module](http://nodejs.org/docs/v0.8.0/api/path.html) you can rewrite it as:
```javascript
var finalElements = [];
_.forEach(elements, function(element) {
    var extension = path.extname(element);
    var basename = path.basename(element, extension);
    if (basename.substring(0, 7) === 'oae.api' && extension.toLowerCase() === '.js') {
         finalElements.push(basename.substr(8))
    }
});
```

The 2 functions underneath this one can be removed then I think