asked on
function PhoneNumMask(const Str: string; const hmask: string): PChar;
var
Pstr, Pmask, ResultStr: PChar;
begin
Pstr := PChar(Str);
Pmask := PChar(hmask);
New(ResultStr);
while Pmask^ <> #0 do
begin
if Pmask^ <> '#' then // a literal character in the mask, output it directly
StrCat(ResultStr,PChar(string(Pmask^)))
else // output a digit
begin
while (PStr^ <> #0) and not (PStr^ in ['0'..'9']) do
Inc(PStr);
if PStr^ = #0 then BREAK; // Exit loop
StrCat(ResultStr,PChar(string(PStr^))); // Tack on a digit to the result string
Inc(PStr);
end;
Inc(Pmask);
end; // while Pmask^ <> #0 do
Result:=ResultStr;
Dispose(ResultStr);
end; // PhoneNumMask