How to extract the beginning of a string (prefix) in Pascal

1 Answer

0 votes
program ExtractPrefix;

var
  str: string;
  prefix: string;
  lengthOfPrefix: Integer;

begin
  str := 'Pascal Programming';
  lengthOfPrefix := 5;  // Length of the prefix you want to extract

  // Extract the prefix
  prefix := Copy(str, 1, lengthOfPrefix);

  WriteLn('Prefix: ', prefix);
end.



(*
run:

Prefix: Pasca

*)

 



answered May 1, 2025 by avibootz
...