I need to eliminate any results from an array that include alphabetic characters. To do this, I am using the following code:
if(gtin.toString().length != 13 || /[a-z\-]+/ig.test(gtin) == true) {
gtin = "null";
}
Although it works for some variables, there are cases where it does not work. For example:
- CS230
- C1
- L3940-noir
Despite using the code above, these variables with alphabets still remain in the array. Any insights on why this might be happening would be greatly appreciated. Thank you!