Grab Last Model Number From Alphanumeric String In MySQL

I ran into this MySQL problem today and couldn’t find a clear-cut answer online so I figured this might be useful to someone else. Suppose you have a table a column that houses alphanumeric substrings, such as is often used for item model identification, eg.:
A1
A2
A3
B1
B2
B3
AB1
AB2
AB3

How would you query the last model number of the A series, for example in order to suggest or autofill the next model’s number? Like so:

SELECT SUBSTR(model FROM 2) as lastModel FROM product WHERE model LIKE 'A%' AND model NOT LIKE 'B%' AND model NOT LIKE 'AB%' ORDER BY CAST(lastModel AS UNSIGNED) DESC LIMIT 1;

What if you you have some models which have an extra code prepended to the model to identify variants? eg.
A1
A2
A3
MA1
MA2
MA3
B2
B3
B3

How would you query the last model of the _A series? We need to get rid of the M character:

SELECT SUBSTR(REPLACE(model, 'M','') FROM 2) as lastModel FROM product WHERE model LIKE 'A%' OR model LIKE 'MA%' ORDER BY CAST(lastModel AS UNSIGNED) DESC LIMIT 1;