How to split a string by dash at specific position JavaScript

How to split a string by dash at specific position JavaScript

I have a dynamically created array as below:

I have a dynamically created array as below:

["171281-0-001-1", "171281-0-001-2"]

Basically, I am creating the value based on a very complex function. But that function does not matter here. Basically for example 171281-0-001-1 is made of Account number + id. 171281-0-001 is Account number and 1 is the id. The number of dashes can be any number but after the last dash it's always id. How can I differentiate these from my value and assign it into different variables?

Tried:

for (let key in this.your_reference) {
  extractedAccountNumber = key.split('-')[0];
  extractedId = key.split('-')[1];
}

But since the dashes can be in any number now, the variables have wrong values. Any idea guys? Thanks in advance

Angular 9 Tutorial: Learn to Build a CRUD Angular App Quickly

What's new in Bootstrap 5 and when Bootstrap 5 release date?

Brave, Chrome, Firefox, Opera or Edge: Which is Better and Faster?

How to Build Progressive Web Apps (PWA) using Angular 9

What is new features in Javascript ES2020 ECMAScript 2020

JavaScript Tutorial: if-else Statement in JavaScript

This JavaScript tutorial is a step by step guide on JavaScript If Else Statements. Learn how to use If Else in javascript and also JavaScript If Else Statements. if-else Statement in JavaScript. JavaScript's conditional statements: if; if-else; nested-if; if-else-if. These statements allow you to control the flow of your program's execution based upon conditions known only during run time.

How to Retrieve full Profile of LinkedIn User using Javascript

I am trying to retrieve the full profile (especially job history and educational qualifications) of a linkedin user via the Javascript (Fetch LinkedIn Data Using JavaScript)

Java vs. JavaScript: Know The Difference

Java vs. JavaScript: Know the Difference, Java vs. JavaScript: What's the Difference? Java vs. JavaScript: Major Similarities and Differences. pros and cons of JavaScript and Java.