//Replace character in string with regex var getcatName = $(location).attr('href'), getCatParts = getcatName.split("/"), endName = getCatParts[getCatParts.length-1], replaceName = endName.replace(/\-/g, ' '); $('#forum-cat').html(replaceName);