I have an array like this...
var array = ['aaa', 'bb', 'ccc', 'dddd', 'eee', 'fff'];
Also, I have a string like this:
5000aaa
or like this...
50bb
That string will vary, I need to put that matching part (aaa
) into a variable and remove it from the existing string.
The final result should be like this:
var array = ['aaa', 'bb', 'ccc', 'dddd', 'eee', 'fff'];
var oldString = '5000aaa';
var matchedPart = 'aaa';
var newString = '5000';
Problem is the matching length is varied, And the string is dynamic (Getting from an input's value) However, every time the matching part only included in the end.
I can't figure out how to do this with pure Javascript or with ES2015 or VueJS. Can anyone guide me?