The regex to handle this is pretty simple:
$firstpart = "A1"
"A11234" -match "^$firstpart\d{4}$" # TRUE
"A121234" -match "^$firstpart\d{4}$" # FALSE
$firstpart = "A12"
"A121234" -match "^$firstpart\d{4}$" # TRUE
"A12123" -match "^$firstpart\d{4}$" # FALSE
"A11234" -match "^$firstpart\d{4}$" # FALSE
You can't use the -Filter to do all of this, use the "$firstpart" to limit the Get-ADComputer and then Select-Object to do the differentiation:
Get-ADComputer -Filter "name -like '$firstpart*'" |
Where-Object {$_.name -match "^$firstpart\d{4}$"}
EDIT: added missing "*" to the filter string, AND added the missing <dollar sign><underbar><period> before the "name" in Where-Object.