Hi guys I am trying to look at a string which looks like this:
'sl-test-one-two'
'sl-test'
var breadcrumbBrand = $(".breadcrumb-navigation__link").last().attr("data-category-id");
var test = breadcrumbBrand.match(\A[^-]+-[^-]+);
console.log(test);
you can use the regex
^[^-]+\-[^-]+
check the demo here
function matchStr(str){
console.log(str.match(/^[^-]+\-[^-]+/g));
}
matchStr('sl-test-one-two');