I Have an array say
['(','C','1','2',')']
Now I want to trim data from array beginning from indexOf('C') + 2 ,If it is a digit I need to remove it from array.. So for the above example final array has to be
['(','C','1',')']
For example if I have ['(','C','1','2','3','*',')'] I want it to be trimmed to ['(','C','1','*',')'] , After element 'C' only one numeral is allowed.
I know I can traverse the array by getting the indexOf('C') and then checking each element for numeric.. but help me with some efficient and better way. like using splice or something.
.splice()or something.... Since you would have to have used.indexOf()to get the indices to do the splice. Another method is joining the array back into a String and performing regex matching.