I need to match the elementId with any other sub element IDs that begin with the elementId. For example, Sub elements have their IDs marked as 1-1, 1-2,...,4-5,..., 8-13, etc. So, if the Element ID is 2, I need to get all the sub elements of this element by filtering (The result should be 2-1, 2-2, 2-3,...) I tried using this pattern but it doesn't work.
var regEx = '/['+elementId+']*/';
//elementsId is a var derived from a previous expression
In order to match this what is the RegExp pattern that I should use? I've provided the code segment below.
jsPlumb.draggable(newAgent, {
containment: 'parent'
});
newAgent.on('click', '.cancel', function (e) {
alert( newAgent.attr('id'));
var elementId= newAgent.attr('id');
var regEx = '/['+elementId+']*/';
alert (regEx);
for(var m=0; m<list.length; m++)
{
if(list[m][0].exec(regEx) || list[m][1].exec(regEx))
{
alert('Deleting connection between ' + list[m][0] + '&' + list[m][1]);
}
}
jsPlumb.detachAllConnections(newAgent.attr('id'));
jsPlumb.removeAllEndpoints(newAgent.attr('id'));
jsPlumb.detach(newAgent.attr('id'));
$(newAgent).remove();
});