string split and combine
<p>What I want to achieve is to split a link with "/" then split again with "-" after last "/"
and change the string after the last "/" but keep the string after the last "-".</p>

<p>For example:</p>

<pre><code>http://example.com/happy_new_year/we-have-cake.html
</code></pre>

<p>I want to change the string after last "/" to "no-more-" but keep "cake" then it will turn into</p>

<pre><code>http://example.com/happy_new_year/no-more-cake.html
</code></pre>

<p>This is what I wrote, ofc doesn't work, need help</p>

<pre><code>var text = link.href;
var slash = text.split("/");
var cross = slash.split("-");
slash[slash.length-1] = "no-more" + cross[cross.length - 1];
link.href = "";
for (var i = 0; i &lt; slash.length; i++)
    link.href = link.href + "/" + slash[i];
</code></pre>
