I don't think that Delphi has any function to parse regular expressions, so I looked on this site http://www.ml-consult.co.uk/foxst-39.htm and found some informations from which i built the following function
function TForm1.CheckIfValid(anInput : String) : Boolean;
var
iSpacePos, i : byte;
sInward, sOutward : String;
begin
Result := False;
if (anInput = EmptyStr) then Exit;
anInput := UpperCase(anInput);
iSpacePos := Pos(' ', anInput);
if iSpacePos = 0 then Exit;
sInward := Copy(anInput, iSpacePos + 1, 3);
sOutward := Copy(anInput, 1, iSpacePos - 1);
if StrToIntDef(sInward[1], -1) = -1 then Exit; //first char has to be a number
//these characters never appear in the inward code
if (AnsiIndexStr(sInward[2], ['C', 'I', 'K', 'M', 'O', 'V']) <> -1) or
(AnsiIndexStr(sInward[3], ['C', 'I', 'K', 'M', 'O', 'V']) <> -1) then Exit;
//build the outward code as the patterns from the site
for i := 1 to Length(sOutward) do
if ord(sOutward[i]) in [65..90] then // or sOutward[i] in ['A'..'Z']
sOutward[i] := 'A'
else sOutward[i] := '9';
if AnsiIndexStr(sOutward, ['A9', 'A99', 'AA9', 'A9A', 'AA99', 'AA9A']) = -1 then Exit;
//the code is valid, so i return true value
Result := true;
end;
If you want to create a more accurate validation, read the entire article from the link I posted.
Ionut