Reasonably simple if the number portion always stays the same length. For the number itself try:
Code:
$(substr,$(getvar,ctab),1,4)
For the rest of the tab's name try:
Code:
$(substr,$(getvar,ctab),6)
The substr diesel function requires the start position number (i.e. the 1 and the 6). The 2nd number is how many characters should be extracted, if this is omitted it extracts all up to the end. The code you had basically calculated the length less 3 for the start point - thus the 4th last position.