JSFiddle - React, Tailwind, and code Playground

JavaScript

var pattern= new RegExp(/\d{1,7}-\d{2}-\d/);

alert(pattern.test("12345678-12-1"));