25.1 AS Level String Functions Overview
- AS Level (9618) uses a different set of string functions from IGCSE.
- Key difference: AS Level uses
LEN,LEFT,RIGHTandMIDinstead of IGCSE'sLENGTHandSUBSTRING. UCASEandLCASEare shared with IGCSE.- All character positions are 1-based (the first character is at position 1).
Common mistake: Using LENGTH or SUBSTRING in an AS Level exam will lose marks — these are IGCSE functions only. Always use LEN, LEFT, RIGHT and MID at AS Level.
AS Level String Functions (2026 syllabus)
LEN(String)— returns the length of the string.UCASE(String)— converts to uppercase.LCASE(String)— converts to lowercase.LEFT(String, n)— returns the first n characters.RIGHT(String, n)— returns the last n characters.MID(String, start, length)— extracts characters from positionstartforlengthcharacters.
DECLARE Word : STRING
Word <- "Computer"
OUTPUT LEN(Word) // Outputs: 8
OUTPUT LEFT(Word, 3) // Outputs: Com
OUTPUT RIGHT(Word, 3) // Outputs: ter
OUTPUT MID(Word, 4, 3) // Outputs: putKey idea: Notice how LEFT(Word, 3) and MID(Word, 1, 3) return the same value. LEFT is just a shortcut for MID starting at position 1.
AS Level String Functions Overview
25.2 LEN, UCASE, LCASE
LEN()returns the number of characters in a string — including spaces and punctuation.- AS Level uses
LEN, NOTLENGTH. UCASE()converts every letter to uppercase.LCASE()converts every letter to lowercase.- Both
UCASEandLCASEleave non-letter characters (digits, spaces, punctuation) unchanged.
DECLARE Word : STRING
Word <- "Hello World"
OUTPUT LEN(Word) // Outputs: 11
OUTPUT UCASE(Word) // Outputs: HELLO WORLD
OUTPUT LCASE(Word) // Outputs: hello worldWatch out: The space in "Hello World" counts as a character. LEN returns 11, not 10. Always include spaces when counting characters.
Exam tip: Use UCASE or LCASE before comparing strings to make the comparison case-insensitive, e.g. UCASE(Input) = "YES" accepts "yes", "Yes" or "YES".
LEN, UCASE, LCASE
25.3 LEFT and RIGHT Functions
LEFT(String, n)— extracts the first n characters from the start.RIGHT(String, n)— extracts the last n characters from the end.- Both take two arguments: the string and the number of characters.
- Useful for: extracting file extensions, getting the first / last character, checking prefixes and suffixes.
DECLARE Word : STRING
Word <- "Computer"
OUTPUT LEFT(Word, 3) // Outputs: Com
OUTPUT RIGHT(Word, 3) // Outputs: ter
OUTPUT LEFT(Word, 1) // Outputs: C
OUTPUT RIGHT(Word, 1) // Outputs: rExtract a file extension
DECLARE File : STRING
File <- "report.pdf"
OUTPUT RIGHT(File, 3) // Outputs: pdfCheck a prefix
DECLARE Code : STRING
Code <- "ID-2026-001"
IF LEFT(Code, 2) = "ID" THEN
OUTPUT "Valid ID"
ENDIFRule of thumb: Use LEFT when the interesting data is at the start of the string (prefixes, initials, codes); use RIGHT when it is at the end (extensions, suffixes, units).
LEFT and RIGHT Functions
25.4 MID Function
MID(String, start, length)extracts characters starting at positionstart(1-based) forlengthcharacters.- Different from IGCSE's
SUBSTRING, which uses the same argument order but is renamed at AS Level. - The second argument is the start position (1-based), and the third is the length to extract.
MID(S, 1, n)is equivalent toLEFT(S, n).
DECLARE Word : STRING
Word <- "Computer"
// 12345678 <- positions
OUTPUT MID(Word, 1, 3) // Outputs: Com
OUTPUT MID(Word, 4, 3) // Outputs: put
OUTPUT MID(Word, 2, 4) // Outputs: ompuWatch the indexing: CIE pseudocode is 1-based. The first character is at position 1, not 0. MID("ABC", 1, 1) returns "A" — calling MID("ABC", 0, 1) would be incorrect.
Exam tip: When you see "extract characters 4 to 6", translate to MID(S, 4, 3) — start at 4, take 3 characters (positions 4, 5, 6). The trick: the length is end − start + 1.
MID Function
25.5 String Processing Techniques
- Combine multiple string functions to solve complex problems.
- Extracting initials:
LEFT(Name, 1)for each word. - Checking prefixes / suffixes: compare
LEFTorRIGHToutput with a target string. - Build formatted output using the
+concatenation operator.
Extract initials from a full name
DECLARE FullName : STRING
DECLARE Initials : STRING
FullName <- "John Smith"
// "J" + "S" = "JS"
Initials <- LEFT(FullName, 1) + MID(FullName, 6, 1)
OUTPUT Initials // Outputs: JSAS Level (9618) — LEFT / MID
Initials <- LEFT(FullName, 1) + MID(FullName, 6, 1)IGCSE — SUBSTRING (DO NOT use at AS Level)
Initials <- SUBSTRING(FullName, 1, 1) + SUBSTRING(FullName, 6, 1)Exam tip: Initials are a classic exam question — combine LEFT / MID with the + operator to extract and join the first letter of each name. If the name has more than two words, use a loop with MID and LEN to walk through each character.
String Processing Techniques
25.6 Practical Examples
Five worked examples showing how to combine AS Level string functions to solve real problems.
Example 1 — Extract a file extension using RIGHT
DECLARE File : STRING
File <- "notes.txt"
OUTPUT RIGHT(File, 3) // Outputs: txtExample 2 — Validate an email format using MID and LEN
DECLARE Email : STRING
Email <- "user@school.com"
// Check the first character is not "@"
IF LEFT(Email, 1) = "@" THEN
OUTPUT "Invalid email"
ELSE
OUTPUT "Looks OK"
ENDIFExample 3 — Convert a name to "Surname, FirstInitial" format
DECLARE FullName : STRING
FullName <- "John Smith"
OUTPUT RIGHT(FullName, 5) + ", " + LEFT(FullName, 1) + "."
// Outputs: Smith, J.Example 4 — Check if a string starts with a specific prefix using LEFT
DECLARE Code : STRING
Code <- "ID-2026-001"
IF LEFT(Code, 2) = "ID" THEN
OUTPUT "Valid ID code"
ELSE
OUTPUT "Invalid code"
ENDIFExample 5 — Extract an area code from a phone number using MID
DECLARE Phone : STRING
Phone <- "07987654321"
// Extract positions 4..7 = "8765"
OUTPUT MID(Phone, 4, 4) // Outputs: 8765Key idea: Most string problems break down into three steps: (1) measure with LEN, (2) slice with LEFT / RIGHT / MID, (3) join with +.
Practical Examples
25.7 Key Points Summary
Recap of every AS Level string concept covered in this topic — memorise these and you will be ready for any AS Level strings question.
AS Level uses: LEN, UCASE, LCASE, LEFT, RIGHT, MID.
IGCSE uses: LENGTH, UCASE, LCASE, SUBSTRING (different!).
LEFT(String, n) — first n characters.
RIGHT(String, n) — last n characters.
MID(String, start, length) — extract from position (1-based).
LEN(String) — character count (NOT LENGTH).
String concatenation uses the + operator.
All positions are 1-based in CIE pseudocode.
UCASE / LCASE do not change the length of the string.
LEFT(S, 1) = MID(S, 1, 1) — both return the first character.
Exam tip: When a question asks you to "count", reach for LEN; when it asks to "extract from the start/end", reach for LEFT / RIGHT; when it asks to "extract from the middle", reach for MID; when it asks to "combine", reach for +.