This depends on the definition of "alphanumerical character" and "puncutation character".
If we for instance define the set of punctuation characters
const
PUNCT = ['.', ',', ':', ';', '-', '!', '?'];
and consider all other characters alphanumeric, then you could do
function RemovePunctuation(const Str: string): string;
var
ActualLength: integer;
i: Integer;
const
PUNCT = ['.', ',', ':', ';', '-', '!', '?'];
begin
SetLength(result, length(Str));
ActualLength := 0;
for i := 1 to length(Str) do
if not (Str[i] in PUNCT) then
begin
inc(ActualLength);
result[ActualLength] := Str[i];
end;
SetLength(result, ActualLength);
end;
This function turns a string into a string. If you want to turn a string into an array of characters instead, just do
type
CharArray = array of char;
function RemovePunctuation(const Str: string): CharArray;
var
ActualLength: integer;
i: Integer;
const
PUNCT = ['.', ',', ':', ';', '-', '!', '?'];
begin
SetLength(result, length(Str));
ActualLength := 0;
for i := 1 to length(Str) do
if not (Str[i] in PUNCT) then
begin
result[ActualLength] := Str[i];
inc(ActualLength);
end;
SetLength(result, ActualLength);
end;
(Yes, in Delphi, strings use 1-based indexing, whereas arrays use 0-based indexing. This is for historical reasons.)