Grade 11 · Practical
Strings and text processing
Structured Programming · about 3 min
Strings hold text. Delphi's string functions let you validate, search and transform input — essential for exam questions and real programs.
Key points- `Length(s)` counts characters; `Copy(s, start, n)` extracts a substring; `Pos(sub, s)` finds a substring's position (0 if absent).
- `UpperCase`/`LowerCase` normalise case; `Trim` removes surrounding spaces.
- Access one character with `s[i]`; loop `for i := 1 to Length(s)` to examine every character.
- Test a character with sets: `if s[i] in ['A'..'Z'] then …`.
- String — a sequence of characters.
- Substring — part of a string extracted with Copy.
- Concatenation — joining strings with `+`.
EXAM TIP
to check a character is a capital letter use `in ['A'..'Z']`; to count vowels, loop the string and test each character.