Redial a number I just called without the extra digits I pressed during the call

If the title doesn’t make sense, I’ll often call someone and be forced to dial their extension or other numbers during the call. My phone remembers all those extra digits so that when I try to redial, I send a larger number to asterisk that it doesn’t know how to process.

Is there a route dial pattern I can use that will take 1NXXNXXXXXXGGGGGGGGGG (where the G is garbage of unknown length) and strip off the G’s to dial 1NXXNXXXXXX?