JSFiddle - React, Tailwind, and code Playground

JavaScript

var str = "text-345-3535",first,second;

str.replace(/(\d+)-(\d+)$/,function(str,p1,p2) {first = p1;second = p2});


alert(first + ' ' + second);