How to resolve the algorithm Substring step by step in the Delphi programming language
Published on 12 May 2024 09:40 PM
How to resolve the algorithm Substring step by step in the Delphi programming language
Table of Contents
Problem Statement
Display a substring:
If the program uses UTF-8 or UTF-16, it must work on any valid Unicode code point, whether in the Basic Multilingual Plane or above it. The program must reference logical characters (code points), not 8-bit code units for UTF-8 or 16-bit code units for UTF-16. Programs for other encodings (such as 8-bit ASCII, or EUC-JP) are not required to handle all Unicode characters.
Let's start with the solution:
Step by Step solution about How to resolve the algorithm Substring step by step in the Delphi programming language
Source code in the delphi programming language
program ShowSubstring;
{$APPTYPE CONSOLE}
uses SysUtils;
const
s = '0123456789';
n = 3;
m = 4;
c = '2';
sub = '456';
begin
Writeln(Copy(s, n, m)); // starting from n characters in and of m length;
Writeln(Copy(s, n, Length(s))); // starting from n characters in, up to the end of the string;
Writeln(Copy(s, 1, Length(s) - 1)); // whole string minus last character;
Writeln(Copy(s, Pos(c, s), m)); // starting from a known character within the string and of m length;
Writeln(Copy(s, Pos(sub, s), m)); // starting from a known substring within the string and of m length.
end.
You may also check:How to resolve the algorithm Brazilian numbers step by step in the Perl programming language
You may also check:How to resolve the algorithm Execute Brain step by step in the Sidef programming language
You may also check:How to resolve the algorithm Forward difference step by step in the SQL programming language
You may also check:How to resolve the algorithm Roots of unity step by step in the Julia programming language
You may also check:How to resolve the algorithm Read a specific line from a file step by step in the D programming language