Strings

AS Level

AS Level Strings

Master the 2026 CIE AS Level (9618) string functions: LEN, UCASE, LCASE, LEFT, RIGHT and MID — the AS Level alternatives to IGCSE's LENGTH and SUBSTRING.

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, RIGHT and MID instead of IGCSE's LENGTH and SUBSTRING.
  • UCASE and LCASE are 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 position start for length characters.
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: put

Key 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.

25.2 LEN, UCASE, LCASE

  • LEN() returns the number of characters in a string — including spaces and punctuation.
  • AS Level uses LEN, NOT LENGTH.
  • UCASE() converts every letter to uppercase.
  • LCASE() converts every letter to lowercase.
  • Both UCASE and LCASE leave 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 world

Watch 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".

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: r

Extract a file extension

DECLARE File : STRING
File <- "report.pdf"
OUTPUT RIGHT(File, 3)   // Outputs: pdf

Check a prefix

DECLARE Code : STRING
Code <- "ID-2026-001"
IF LEFT(Code, 2) = "ID" THEN
  OUTPUT "Valid ID"
ENDIF

Rule 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).

25.4 MID Function

  • MID(String, start, length) extracts characters starting at position start (1-based) for length characters.
  • 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 to LEFT(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: ompu

Watch 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.

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 LEFT or RIGHT output 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: JS

AS 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.

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: txt

Example 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"
ENDIF

Example 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"
ENDIF

Example 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: 8765

Key idea: Most string problems break down into three steps: (1) measure with LEN, (2) slice with LEFT / RIGHT / MID, (3) join with +.

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 +.

Question Bank

Answer all questions, then press Submit Quiz to see your score.

0/12 answered

Question 1Multiple Choice

What does LEN("Hello World") return in AS Level pseudocode?

Question 2True / False

AS Level pseudocode uses the SUBSTRING function to extract characters from a string.

Question 3Multiple Choice

DECLARE Word : STRING
Word <- "Computer"
OUTPUT MID(Word, 4, 3)

Question 4True / False

LEFT("Hello", 2) returns "He".

Question 5Multiple Choice

Which expression extracts the initials "JS" from FullName = "John Smith" using AS Level functions?

Question 6Multiple Choice

DECLARE S : STRING
S <- "Hello"
OUTPUT LEFT(S, 2) + RIGHT(S, 2)

Question 7True / False

In AS Level pseudocode, MID uses 1-based indexing (the first character is at position 1).

Question 8Multiple Choice

A filename File = "report.pdf" is stored. Which expression extracts the file extension "pdf"?

Question 9Multiple Choice

DECLARE Word : STRING
Word <- "abc"
OUTPUT LEN(UCASE(Word))

Question 10True / False

LEFT(String, 1) always returns the same character as MID(String, 1, 1).

Question 11Multiple Choice

You want to convert FullName = "John Smith" into "Smith, J.". Which expression is correct?

Question 12True / False

AS Level pseudocode uses the LEN function instead of LENGTH.

Answer all 12 questions to enable submission.