jQuery - regex method

0 votes
260 views
added May 2, 2018 in Regex by LC Marshal Captain (25,790 points)
edited Jul 13, 2018 by LC Marshal
//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);

 

lazacode.org - Malaysia's programming knowledge sharing platform, where everyone can share their finding as reference to others.
...