String: 56abc67xyz, 56abc67xyz68xyz, 12abc69xyzA
Output: 56abcxyz, 56abc67xyzxyz, 12abc69xyzA
So, the numbers occurring right before xyz should be removed but there shouldn't be anything after the xyz. It should be the last thing in the string.
CODE:
mystring.replace(/\d+xyz$/, '')
This code will remove the last xyz but I want to keep it as in example above.