I need to remove a prefix from a string. Given an array of known prefixes, I do not know which prefix will exist in a string. One and only one prefix will exist.
function CleanupSupportedItems(data) {
var prefixes = new Array("TrialLeads", "IPG");
for (var i = 0; i < prefixes.length - 1; i++) {
var prefix = new RegExp(/prefixes[i]/g);
//alert(prefix);
data = data.replace(prefix, "");
alert(data);
}
}
The above code returns undefined on the second iteration.
Given the call
CleanupSupportedItems("TrialLeads11");
I want a return value of "11". How can I do it?