LastMatchOnLine

The function 'match' sets RSTART to the index of each match and RLENGTH to its length, and returns 0 when no matches exist. To find the last match on a line, then, all that is necessary is to call it and remove the match until it no longer finds matches, and take the final match.

function lastmatch(re, line,        result) {
    while(match(line, re)) {
        result = substr(line, RSTART, RLENGTH)
        line = substr(line, RSTART+RLENGTH)
    }
    return result
}