Underlining specific letters using jQuery

I've used this for a few sites, and can't remember where I first got it from, but its developed along the way!

Last two letters in a Header

This was my original use, and it probably could read better using variables, but as a quick and dirty code lift to serve my purposes I was n't overly fussed.

$('.heading').each(function() {
    $(this).html(
        $(this).html().substr(0, $(this).html().length-2)
        + "<span class='lines'>"
        + $(this).html().substr(-2)
        + "</span>"
    );
});
	  

Middle two letters in a heading

This was a later project, and the nature of making it the middle charachters made it a bit harder, so to keep it cleaner and easier to read I added variables. 

$('.largeBoldUnderline span').each(function() {
    var str =  $(this).html()
    var middle = $(this).html().length/2;
    var underline = str.substr(middle-1, 2);
    
    $(this).html(
        str.substr(0, middle-1)
        + "<span class='lines'>"
        + underline
        + "</span>"
        +  str.substr(middle+1)
    );
});
10