REGEX doesn't work in Node.enumerateChildren

Hello everyone,

I’m new in Cocos2d-x framework, I’m trying to enumerate the children nodes using Node.enumerateChildren(), so I need get nodes that their name starting with “btnA_D#” where “#” indicates the button number, e.g: btnA_D1, btnA_D2, etc. Then I’m using a regular expression like this "btnA_D[0-9]+". This is my code:

var mainscene = ccs.load(res.MainScene_json);
this.addChild(mainscene.node);
var buttons = new Array();
var cll = function (node){
            buttons.push(node);
            console.log(node);
};
mainscene.node.enumerateChildren("btnA_D[0-9]+", cll);

It doesn’t work, after I debugged and I found in the line 2541 in the “CCNode.js” file, that:

        (child._name.indexOf(searchName) !== -1){

I think that indexOf(searchName) doesn’t have the correctly behaviour for satisfy the description in documentation. I replaced that line for this:

       var patt = new RegExp(searchName);
        if (patt.test(child._name) !== false){

And it solved my problem. So I think that is a bug but what do you think?. Thanks in advance and excuse me for my bad english.

I think you are right…

API info:

enumerateChildren(name, callback)
Search the children of the receiving node to perform processing for nodes which share a name.

Parameters:

name
The name to search for, supports c++11 regular expression. Search syntax options: //: Can only be placed at the begin of the search string. This indicates that it will search recursively. ..: The search should move up to the node’s parent. Can only be placed at the end of string. / : When placed anywhere but the start of the search string, this indicates that the search should move to the node’s children.

callback
A callback function to execute on nodes that match the name parameter. The function takes the following arguments: node A node that matches the name And returns a boolean result. Your callback can return true to terminate the enumeration.

So I’m wondering, could I push my code to the repository for the team evaluate my code or how can I contribute and I do a push request. So anyone could bring me information or something. Thanks in advance and excuse me for my bad english.