JSFiddle - React, Tailwind, and code Playground
JavaScript
var curUrl = window.location.href;
alert(curUrl);
// test regex
var langCode = 'no';
var curUrl = 'http://local.test.dk:3000/#';
var newUrl = curUrl.replace(/(http:\/\/local.test.)dk(:3000\/#)/, '$1'+langCode+'$2');
alert(newUrl);